Find Lucky Integer in an Array | Leetcode 1394

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 4

  • @x-menofficial007
    @x-menofficial007 Год назад +1

    Well explained, mem 🎉 🤩

  • @chinmayjain9705
    @chinmayjain9705 Год назад

    nice explanation 😇👍

  • @chinmayjain9705
    @chinmayjain9705 Год назад +2

    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