You are viewing a single comment's thread. Return to all comments →
While this works, you loop through the complete collection of values 3 times. First while reading it in the scanner. Second while scanning for the max value in the collection after reading it in and third to count the number of times it was found.
anyway the time complexity is O(n+n+n) = O(n)
I'm not too familiar with the BigO notation, so an honest question how does it become n+n+n shouldn't it be 3n rather as you are doing full loops over all elements?
In BigOh notation, I believe they drop the constants in front of n because exponents matter so much more that the constants are negligible.