```
public class Solution {
public int majorityElement(int[] nums) {
int len = nums.length;
int flag = 1;
for (int i = 0; i < len; i++) {
for (int j = i + 1; j < len; j++) {
if (nums[j] == nums[i])
flag++;
if (flag > len / 2) return nums[i];
}
flag = 1;
}
return 0;}}
```