You are viewing a single comment's thread. Return to all comments →
Now if you see this code works only if your first element(number) in your array is highest always.. If not it will not work.
Take this example where you have 4 elements - '1 2 4 4' now what see what your code does,
your answer s=1 where as the answer should have been 2 as maximum height is 4 and it occurs twice. Hope that this is useful.
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
Now if you see this code works only if your first element(number) in your array is highest always.. If not it will not work.
Take this example where you have 4 elements - '1 2 4 4' now what see what your code does,
your answer s=1 where as the answer should have been 2 as maximum height is 4 and it occurs twice. Hope that this is useful.