Matrices pattern
Island Perimeter
A grid of 0s (water) and 1s (land) contains exactly one island with no lakes. Return the perimeter of that island. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 463
- 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 463
Easy
From the first idea to the best one
- 01 Brute force · check four sides O(R · C)O(1) space
- 02 Optimized · 4 per cell − 2 per shared edge O(R · C)O(1) space
What you will learn
- How to read Island Perimeter and spot the matrices pattern in it
- Brute force · check four sides: O(R · C) time, O(1) space
- Optimized · 4 per cell − 2 per shared edge: O(R · C) 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 Island Perimeter 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.