#one of the algo i.e easy to implement#
Look here you can use hash map i.e HashMap<Integer,Integer> map=new HashMap(Integer,Integer).. as whenever you see new elements make that entry in hash map and intialize its count to 1...i.e map.put(arr[i],1) and next time when the same element is seen you can add 1 to the count by fetching its value i.e count=map.get(arr[i])+1...now check whether this count is greater than n/2 or not if yes print majority element found and return and if not than put this count value i.e map.put(arr[i],count)...so time complexity here is just O(n) as there would be just one for loop...and space complexity here would be O(n) due to hash map data structure