@joker_batman Once you sort, you just need to pick the middle element from the array. Probably don't need to iterate again. That's because majority element by definition will appear more than half the elements in the array. Thanks.

I guess we should not use prices[i+1] since we do not know the stock price in advance. Only on day 'i', you will get to know the stock price of ith day.

Neat solution!
I also wonder that why can't we map the character in String pattern to the word in String[] words, but instead map both of them to the index Integer?

int newResult = result * 10 + tail;
if ((newResult - tail) / 10 != result)

if ((newResult - tail) / 10 != result) is always true .... you can take it out

replacing newResult with result * 10 + tail will not equal result, in other words:
1- if (result * 10 + tail -tail) / 10 != result)
2- if (result * 10) / 10 != result)
3- if (result != result) , no use !!

There is a bug: if the preorder traversal of the tree is [1,-2147483648,0],then the result would be [1,-2147483648,-2147483648], not [0,-2147483648,1], the idea of this solution may be wrong.