List the Key and Value of Every Map Entry
Updated
Problem statement
A finite Map is represented by parallel arrays keys and values: the entry at index i has key keys[i] and value values[i]. Each key occurs once.
Return all entries as rows [key, value], in the same order as the input arrays. For an empty Map, return an empty array. Do not sort the entries or change either string.
Function
listMapEntries(keys: String[], values: String[]) → String[][]Examples
Example 1
keys = ["beta","alpha"]values = ["2","1"]return = [["beta","2"],["alpha","1"]]The beta entry is listed first because it occurs first in the supplied Map representation.
Example 2
keys = ["name","role"]values = ["Ana",""]return = [["name","Ana"],["role",""]]Each key stays paired with its own value, including the empty role value.
Constraints
0 <= keys.length <= 100andkeys.length == values.length.1 <= keys[i].length <= 20and0 <= values[i].length <= 40.- Keys are distinct strings. All key and value characters are printable ASCII (code 32 through 126).
More Newgen Software interview questions
Similar questions at other companies
- Pizza Price CalculatorMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Cross-Day User Trust ScoresAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
- Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
- Best Average Student ScoreGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
- Two SumOptimus Information · ONSITE INTERVIEWOptimus Information interview questions
- Keep the First Key for Each Distinct ValueOneTrust · ONSITE INTERVIEW
- Two Positions That Add Up to a TargetDocuSign · PHONE SCREEN · ONSITE INTERVIEWDocuSign interview questions
- Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions