Find the Runner-Up Score!

  • + 0 comments

    Am I wrong that this solution is > O(n)? This problem can be done in linear time, no? Python's max() is O(n) and you call it twice each iteration and only luckily reduce n by 1 each iteration. The set [2,2,2,2,2] would have like 30 comparisons to find max plus 5 for your z initialization and then 0 for the print I believe. 5+5+4+4+3+3+2+2+1+1+0+0 [1,2] would be 2+2+1 [1,7,3] would be 3+3+2