1394.找出数组中的幸运数,计数排序简单易懂0ms
作者:互联网
class Solution {
public int findLucky(int[] arr) {
int[] result = new int[501];
for(int i = 0; i < arr.length; i++){
result[arr[i]]++;
}
for(int i = 500; i > 0; i--){
if(result[i] == i) return i;
}
return -1;
}
}
标签:arr,return,0ms,int,++,result,new,易懂,1394 来源: https://blog.csdn.net/Split_token/article/details/122741762