Second-Highest Distinct Salary
Updated
Problem statement
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[]) → intExamples
Example 1
salaries = [50000,70000,70000,60000]return = 60000The distinct salaries are 70000, 60000, and 50000.
Example 2
salaries = [42000,42000]return = -1Only 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