FastPrepSecond-Highest Distinct Salary
Problems/Second-Highest Distinct Salary

Second-Highest Distinct Salary

EPAM logoEPAM● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a task about the second-highest salary in a collection. We chose that salaries must be distinct, the value to return when there is no answer, the limits, and the function signature. Our version is about 88% the same as the reported question.

Given an integer array salaries, return the second-highest distinct salary.

Return -1 if fewer than two distinct salaries are present.

Function

secondHighestSalary(salaries: int[]) → int

Examples

Example 1

salaries = [50000,70000,70000,60000]return = 60000

The distinct salaries are 70000, 60000, and 50000.

Example 2

salaries = [42000,42000]return = -1

Only one distinct salary exists.

Constraints

  • 1 <= salaries.length <= 100000.
  • 0 <= salaries[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
  • Count Array Element FrequenciesPHONE 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

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 secondHighestSalary(int[] salaries) {
        // Write your code here.
    }
}
Checking account…