```
public class Solution {
public int majorityElement(int[] nums) {
for (int i=0;i<5;i++)
{
int v1=((int)(Math.random()*nums.length*10))%nums.length;
if(isMajor(nums,nums[v1]))
return nums[v1];
}
return 0;
}
public boolean isMajor(int[] nums,int v)
{
int n=0;
for (int i=0;i<nums.length;i++)
{
if(nums[i]==v)
n++;
}
return n>nums.length/2;
}
}
```