Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2711. Difference of Number of Distinct Values on Diagonals
For each cell in an m×n grid, compute answer[r][c] = |(# distinct values strictly on the diagonal above‑left of (r,c)) − (# distinct values strictly on the diagonal below‑right of (r,c))|. The key is to process each bottom‑right diagonal independently and derive per‑cell prefix/suffix distinct counts to fill the answer matrix efficiently.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.