Find Lucky Integer in an Array | Leetcode 1394

preview_player
Показать описание
Find Lucky Integer in an Array
Leetcode problem number 1394

JAVA interview programming playlist:

#java #interviewquestions #leetcode
Рекомендации по теме
Комментарии
Автор

public int findLucky(int[] arr) {
int[] numbers = new int[501];

for (int j : arr) {
numbers[j]++;
}

for (int i = 500; i > 0; i--) {
if (i == numbers[i]) return i;
}
return -1; if we use this way then we don't have to use max func

chinmayjain