Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
7 votes
3 answers
2k views

Finding the majority element in an array

A list is said to have a “majority element” if more than half of its entries are identical. In this classical problem the goal consists of determining whether a list a of length n has a majority ...
Soner from The Ottoman Empire's user avatar
2 votes
2 answers
177 views

Recursive Transversal (Python)

For a programming challenge I was doing, I needed to traverse a list of lists, and while writing the standard 2D traversal function, I thought why not generalise it, so I did. Here's my best effort: ...
Tobi Alafin's user avatar
  • 1,792
12 votes
1 answer
2k views

Flatten an array of integers in Python

The goal is to flatten an array of nested arrays of integers. For example [1, [2], [3, [4]]] should return [1, 2, 3, 4] I'm ...
Nikolay Derkach's user avatar
3 votes
5 answers
2k views

count all array[index] == index occurrences

The method foo gets a sorted list with different numbers as a parameter and returns the count of all the occurrences such that: ...
user32385's user avatar