FastPrepMerge Keyed 2D Arrays
Problems/Merge Keyed 2D Arrays

Merge Keyed 2D Arrays

WhatNot logoWhatNot● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An internship report names merging two-dimensional arrays without a full statement. Our version is about 55% the same as that description. Keyed rows, adding values, ordering, empty inputs, and limits define our reading.

Merge the two integer arrays first and second.

For this exercise, each row is a pair [key, value]. Each input is sorted by strictly increasing key, so a key appears at most once in each input.

  • If a key appears in both arrays, add its values.
  • If it appears in just one array, keep its value.
  • Return one row for every distinct key, in increasing key order.

Either input may be empty.

Function

merge2DArrays(first: int[][], second: int[][]) → int[][]

Examples

Example 1

first = [[1,4],[3,2]]second = [[2,7],[3,5]]return = [[1,4],[2,7],[3,7]]

Key 3 appears in both arrays, so its values sum to 7. Other keys retain their values.

Example 2

first = []second = [[5,9]]return = [[5,9]]

An empty first array leaves the second array unchanged.

Example 3

first = [[1,2]]second = [[1,3]]return = [[1,5]]

Equal keys produce one merged row, rather than two rows.

Constraints

  • For this exercise, assume 0 <= first.length, second.length <= 100.
  • Each row contains exactly two integers.
  • Keys are between 1 and 1000; input values are between 1 and 10000.
  • Keys are strictly increasing within each input.

More WhatNot Phone Screen questions

  • Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey Paths from a Log StreamPHONE SCREEN · Seen Nov 2026
  • Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
  • Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
  • Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
  • Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Repeated Shortest Word Distance QueriesLinkedIn · PHONE SCREENLinkedIn interview questions
  • Disjoint Target-Sum TripletsAmerican Express · PHONE SCREENAmerican Express interview questions
  • Sparse Vector Dot ProductAnduril · PHONE SCREENAnduril interview questions
  • Unique Pairs in a 2D Matrix Summing to TargetAmazon · PHONE SCREEN
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Find Two-Sum or Three-Sum Index CombinationsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Efficient TeamsExpedia · OAExpedia interview questions
  • Sparse Vector Dot Product from TuplesMeta · ONSITE INTERVIEWMeta interview questions
  • Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions

Interview reports that mention this question

  • Whatnot interviews · April 2025

WhatNot interview experiences

  • Whatnot OA · 2024
  • Whatnot OA · November 2023
  • Whatnot interviews · November 2023
  • Whatnot interviews · February 2024
  • Whatnot interviews · March 2024
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public int[][] merge2DArrays(int[][] first, int[][] second) {
        // write your code here
    }
}
Checking account…