Sort Custom Records
Updated
Problem statement
Each string in records has the form name|score, where name contains lowercase letters and score is a nonnegative integer.
Return the records sorted by score in descending order. Break equal-score ties by name in ascending lexicographic order.
Function
sortRecords(records: String[]) → String[]Examples
Example 1
records = ["ana|7","bob|10","amy|7"]return = ["bob|10","amy|7","ana|7"]The score-10 record comes first; the score-7 tie is ordered by name.
Example 2
records = ["z|0"]return = ["z|0"]A single record is already sorted.
Constraints
1 <= records.length <= 10000.- Every record follows
name|score. - Names are nonempty lowercase strings; scores are between
0and10^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
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Parse and Sort Integer DataLegora · PHONE SCREEN
- Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
- Find All Word Occurrences in TextSentry · PHONE SCREENSentry interview questions
- Folder Snapshot DiffAirbnb · PHONE SCREENAirbnb interview questions
- Anagrams of a Word in a Word ListZillow · PHONE SCREEN · ONSITE INTERVIEWZillow interview questions
- Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
- Merge Weekday and Time IntervalsNextdoor · PHONE SCREENNextdoor interview questions
- Group AnagramsWorkday · PHONE SCREEN