## 找出数组中出现次数大于n/2的元素 原

I
Iter_迟cH1

``````public class Solution {
public int majorityElement(int[] nums) {
int temp = 0;
int count = 0;
for(int i=0;i<nums.length;i++){
if(count == 0){
temp = nums[i];
count++;
}
else{
if(temp == nums[i]){
count++;
}
else{
count--;
}
}
}
return temp;
}
}``````

I

### Iter_迟cH1

1111111111111 算法汇总

01/03
0
0
LeetCode算法题-Majority Element（Java实现）

11/24
0
0
169. Majority Element。

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and ......

Leafage_M
01/06
0
0

XJ_hello
2016/12/19
57
0
448. Find All Numbers Disappeared in an Array。

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not ap......

Leafage_M
2017/12/05
0
0

Andrew Ng教你如何引领公司进入AI时代

7分钟前
0
0

focusone
28分钟前
3
0
Spring AOP 切面编程记录日志和接口执行时间

39分钟前
5
0
15个Spring的核心注释示例

java菜分享
45分钟前
2
0
[LintCode] Binary Tree Level Order Traversal（二叉树的层次遍历）

honeymose
54分钟前
2
0