@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.
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 !!