2 ms·
Yeah one of the worst offenders of this are the leetcode problems that have a clever but extremely elegantly simple greedy algorithm (such as "return True" lol)
by viccis 2mo ago
Yeah one of the worst offenders of this are the leetcode problems that have a clever but extremely elegantly simple greedy algorithm (such as "return True" lol). Great example is Majority Element [1]
The answer seems pretty clear when you think about it enough, even the proof seems like it makes sense. The problem is marked Easy on Leetcode. But coming up with the algorithm and proving its correctness is a two-name algorithm with its own Wikipedia article. In your example, the challenge isn't even really to "design" that algorithm, it's to prove that it's true.
1: https://leetcode.com/problems/majority-element https://leetcode.com/problems/majority-element
2: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_v...