We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Your code will give wrong answer for the sequence 1,1,1,2,2,2,3,4,5,5,5,5,6,7. Because 'pos' will written the position of 5. Final sequence will be either 4,5,5,5,5 or 5,5,5,5,6 according to your code as frequency of 5 is maximum whereas 1,1,1,2,2,2 is the actual answer
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
Your code will give wrong answer for the sequence 1,1,1,2,2,2,3,4,5,5,5,5,6,7. Because 'pos' will written the position of 5. Final sequence will be either 4,5,5,5,5 or 5,5,5,5,6 according to your code as frequency of 5 is maximum whereas 1,1,1,2,2,2 is the actual answer