Matrices pattern

Find Missing and Repeated Values

An n×n grid should contain every integer from 1 to n² exactly once, but one value appears twice and another is missing. Return [repeated, missing]. Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 2965
  • Easy
  • 2 approaches

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

MatricesLeetCode 2965

Easy

From the first idea to the best one

  1. 01 Brute force · count occurrences O(n²)O(n²) space
  2. 02 Optimized · sums and squares O(n²)O(1) space
Each approach plays step by step, with its time and space.

What you will learn

  • How to read Find Missing and Repeated Values and spot the matrices pattern in it
  • Brute force · count occurrences: O(n²) time, O(n²) space
  • Optimized · sums and squares: O(n²) time, O(1) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Matrices

See Find Missing and Repeated Values run, step by step

Sign in and this page opens on the animation, with all 5 Matrices problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.