lists, an array of lists, each sorted in non-decreasing order. Pick two numbers from two **different** lists, one from each.
Return the largest possible absolute difference between the two numbers.lists=[[-3, 0, 7], [2, 5], [10, 11]] → 14
Take −3 from the first list and 11 from the third: the gap is 14.
lists=[[-5, 20], [1, 2]] → 19
−5 and 20 come from the same list and do not count. Across lists the best is 20 and 1, a gap of 19.
lists=[[6], [6], [6]] → 0
All numbers are equal, so the gap is 0.
lists.length ≤ 10⁵lists[i].length ≤ 500lists[i][j] ≤ 10⁴lists[i] is sorted in non-decreasing orderlists=[[-3, 0, 7], [2, 5], [10, 11]]
14
Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.