Convert an Entry List to a Map
Updated
Problem statement
Each string in entries has the form key=value.
Convert the list into key-value rows. When a key appears more than once, keep its last value. Return rows as [key, value], sorted by key in ascending lexicographic order.
Function
listToMap(entries: String[]) → String[][]Examples
Example 1
entries = ["color=blue","size=large","color=green"]return = [["color","green"],["size","large"]]The final color replaces the earlier value, and keys are sorted.
Example 2
entries = ["a=1"]return = [["a","1"]]One entry produces one row.
Constraints
1 <= entries.length <= 10000.- Keys and values are nonempty lowercase alphanumeric strings.
- Each entry contains exactly one
=.
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
- 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
- Partition and Group Values by ParityPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
- Folder Snapshot DiffAirbnb · PHONE SCREENAirbnb interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Process Shopping Records, Promotions, and Display OrderInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
- Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
- Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
- Group AnagramsMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
- Stable Top K Frequent WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions