Convert an Entry List to a Map
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.