FastPrepList the Key and Value of Every Map Entry
Problems/List the Key and Value of Every Map Entry

List the Key and Value of Every Map Entry

Newgen Software logoNewgen Software● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in the in-person technical round of a Newgen Software interview. One of the Java questions was to go through a Map and output every key together with its value. The report does not say whether code was written or how the output should look.

Here the Map is given as two string arrays, keys and values, and every key is unique. You return each entry as a [key, value] row in input order instead of printing it.

Our version is about 75% the same as the reported question.

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 <= 100 and keys.length == values.length.
  • 1 <= keys[i].length <= 20 and 0 <= 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

  • Reverse a String ManuallyPHONE SCREEN · Seen Oct 2026
  • Employees Who Joined More Than a Week AgoPHONE SCREEN · Seen Oct 2026

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
See Newgen Software hiring insights
Saved
class Solution {
    public String[][] listMapEntries(String[] keys, String[] values) {
        // Write your code here
    }
}
Checking account…