As reported: SAP Concur Software Engineer (USA, internal transfer, 2026), virtual technical rounds: one of the DSA questions was finding the unique rows in a 2D array (matrix). The SQL part of the rounds also asked how to find unique rows in a table (
DISTINCTvsGROUP BY).
Given an m × n integer matrix, return its distinct rows: every row that appears in the matrix, exactly once, in the order of its first appearance.
Example 1
matrix = [[1,1,0,1],
[1,0,0,1],
[1,1,0,1]]
-> [[1,1,0,1],[1,0,0,1]]
Example 2
matrix = [[0,1,0],[0,1,0]] -> [[0,1,0]]
Constraints: 1 ≤ m ≤ 2·10^4; 1 ≤ n ≤ 20; m · n ≤ 2.5·10^5; −10^9 ≤ matrix[i][j] ≤ 10^9.
Code runner format: one line: the matrix as a JSON array of rows. Implement uniqueRows(matrix); the harness prints the list of rows as JSON.