Question: Given an array of integers arr, a lucky integer is an integer which has a frequency (how many times an element occurswithin the array) in

Given an array of integers arr, a lucky integer is an integer which has a frequency (how many times an element occurswithin the array) in the array equal to its value.Return a lucky integer in the array. If there are multiplelucky integers return the largest of them. If there is no lucky integerreturn -1Example 1:Input: arr = [2,2,3,4]Output: 2Explanation Ihe only lucky number in the array is 2 because it occurs twice within the array which is equal to itS value 2.Example 2:Input: arr [1,2,2,3,3,31Output: 3Explanation:1, 2 and 3 are all lucky numbers and the largest is returnedExample 3:TeInput: arr = [2,2,2,3,3]Output: -1ExplanationThere are no lucky numbers in the array because 2 occurs 3 times and 3 occurs twice in the arrayExample 4:Input: arr [51 Output1Something wrong with the question or blank content?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!