Practice
Set Matrix Zeros
Given an m x n matrix of 0s and 1s, if an element is 0, set its entire row and column to 0.
Do it in place.
Example
Given array A as
1 | 1 0 1 |
On returning, the array A should be :
1 | 0 0 0 |
1 | public class Solution { |
First Missing Integer
Given an unsorted integer array, find the first missing positive integer.
Example:
Given [1,2,0]
return 3,
[3,4,-1,1]
return 2,
[-8, -7, -6]
returns 1
Your algorithm should run in O(n)
time and use constant space.
1 | public class Solution { |
Rotate Matrix
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
You need to do this in place.
Note that if you end up using an additional array, you will only receive partial score.
Example:
If the array is
1 | [ |
Then the rotated array becomes:
1 | [ |
1 | public class Solutoion { |