public int majorityElement(int[] num) {
Arrays.sort(num);
int mid=(num.length1)/2;
return num[mid];
}
Dose this one is available during interview?

How can Arrays.sort be used during interview?
By the way, sort() use O(nlgn), but a better solution just uses O(n)int majorityElement(vector<int> &num) { if(!num.size()) return 0; if(num.size()<=2) return num[0]; int a(0),base(0); for(int number : num) { if(a == 0number == base) { base = number; ++a; } else { a; } } return base; }