Find Lucky Integer in an Array Problem
Find Lucky Integer in an Array Problem — ExecCode Easy DSA Practice
Solve the Find Lucky Integer in an Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value. Your task is to compute the required answer and return the largest lucky integer in the array. If there is no lucky integer return -1.
Examples
Input {"arr": [2, 2, 3, 4]}; Output 2. Input {"arr": [1, 2, 2, 3, 3, 3]}; Output 3
Constraints
1 <= arr.length <= 500 1 <= arr[i] <= 500
Practice Find Lucky Integer in an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.