FastPrepFrequency Equals Card Value
Problems/Frequency Equals Card Value

Frequency Equals Card Value

InMobi logoInMobi● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source title suggests a different deck-grouping problem, but its body and examples consistently ask whether some card value equals its own frequency. The judged core task follows that body at about 96%.

You are given an integer array deck, where each integer is the value written on one card.

Return true if there is at least one integer x that appears exactly x times in deck. Otherwise, return false.

Function

hasValueWithMatchingFrequency(deck: int[]) → boolean

Examples

Example 1

deck = [1,1,1,2,2,3]return = true

The value 2 appears exactly 2 times, so the condition is satisfied.

Example 2

deck = [1,1,2,2,2,3,3]return = false

The frequencies of values 1, 2, and 3 are 2, 3, and 2. None equals its card value.

Constraints

  • 2 <= deck.length <= 10^4
  • 1 <= deck[i] <= 4 * 10^4

More InMobi problems

  • Validate a Bracket SequenceOA · Seen Oct 2026
  • Validate a Bracket SequenceOA · Seen Oct 2026
  • Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public boolean hasValueWithMatchingFrequency(int[] deck) {
        // Write your code here
    }
}
Checking account…