#2711

Difference of Number of Distinct Values on Diagonals

specialist · 640 · lc medium +30 · 68.4% accepted · 143 likes · top 75%

Description

For each cell (r, c) in an m x n integer grid, set answer[r][c] = |leftAbove - rightBelow|, where leftAbove is the count of distinct values strictly above-left on the same diagonal and rightBelow is the count strictly below-right. Return the resulting answer matrix.

Code

1
2
3