FastPrepCount Array Element Frequencies
Problems/Count Array Element Frequencies

Count Array Element Frequencies

EPAM logoEPAM● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a well-known task. We chose the function signature, a fixed order for the output, and the limits. Our version is about 98% the same as the reported question.

Given an integer array values, count how many times each distinct value appears.

Return a two-dimensional integer array in which each row is [value, frequency]. Sort the rows by value in ascending order.

Function

countFrequencies(values: int[]) → int[][]

Examples

Example 1

values = [4,2,4,3,2,4]return = [[2,2],[3,1],[4,3]]

The value 2 appears twice, 3 appears once, and 4 appears three times.

Example 2

values = [-1,-1,0,5,0]return = [[-1,2],[0,2],[5,1]]

Negative and zero values are counted normally, and rows remain ordered by value.

Example 3

values = [7]return = [[7,1]]

The only value appears once.

Constraints

  • 1 <= values.length <= 10^5.
  • -10^9 <= values[i] <= 10^9.

Source note: Author-written prompt excerpt retained for source fidelity.

More EPAM Phone Screen questions

  • Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
  • Container With Most WaterPHONE SCREEN · Seen Oct 2026
  • Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
  • Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
  • Group AnagramsPHONE SCREEN · Seen Oct 2026
  • Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
  • Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
  • Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
  • Next Greater Element IPHONE SCREEN · Seen Oct 2026
  • Partition and Group Values by ParityPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Values Exclusive to the Current UserMeta · PHONE SCREENMeta interview questions
  • Count Values Appearing Exactly OnceAgoda · PHONE SCREENAgoda interview questions
  • Top Two Users by Total Purchase AmountSnowflake · PHONE SCREENSnowflake interview questions
  • Restaurant Vote LeadersZipRecruiter · PHONE SCREEN · ONSITE INTERVIEWZipRecruiter interview questions
  • AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions
  • Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
All EPAM interview questionsSee EPAM hiring insights
Saved
class Solution {
    public int[][] countFrequencies(int[] values) {
      // write your code here
    }
}
Checking account…