Leetcode 961 N-Repeated Element in Size 2N Array
作者:互联网
class Solution {
public int repeatedNTimes(int[] A) {
int ans=0;
int len=A.length;
int lenby2=len/2;
for(int i=0;i<len;++i){
int temp=0;
for(int j=0;j<len;++j){
if(A[i]==A[j]){
temp++;
}
}
if(temp==lenby2){
ans=A[i];
break;
}
}
return ans;
}
}
标签:repeatedNTimes,961,int,Solution,len,Element,Array,class 来源: https://blog.csdn.net/polanwind/article/details/88100729