This test case seems to be wrong:
Input: [1,2,3,4,5,6,7,8,9,0]
Expected Output: [7,6,3,0,5,9,1,2,4,8]
We don't have duplicates in this tree, how come the numbers in the expected output are so large?
Thanks.
Mode is the the number which appears most often in a set of numbers.
For the given input [1,2,3,4,5,6,7,8,9,0], each number repeats once at max, so output will be all elements in array. For input [1,8,8,3,3,4] output will be [8,3] as max number of occurrence is '2' and 8 ,3 appears twice.
@sayali.joshi Ok, in this case why is the output solution is in a different order than the input?
@code4fun2016 The output solution has different order is because the problem says that the output could in any order, and a simple way for this problem is to use hashmap to store all the information, which has no order at all. If we extract final solution from hashmap, then the output is definitely not the original order of the input without sorting. Hope this explanation will help you.