All Questions
4 questions
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 ...
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:
...
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 ...
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: ...