ONECARD Hiring | Merge Two 2D Arrays by Summing Values | Off-Campus OA (2022)

Question · Posted Jun 2026

Problem Statement You are given two sorted 2D arrays nums1 and nums2. Each element is represented as:   [id, value] IDs within each array are unique. Arrays are sorted by ID. Merge both arrays such that: If an ID exists in both arrays, sum their values. If an ID exists in only one array, keep its value. Return the merged result sorted by ID. Example Input nums1 = [[1,2],[2,3],[4,5]] nums2 = [[1,4],[3,2],[4,5]] Output [[1,6],[2,3],[3,2],[4,10]] Explanation ID 1 → 2 + ...

The full answer & interview discussion are available to premium members.

Log in Create a free account