Find majority element in an array in linear time