Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.
Example 1:
1 | Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] |
Example 2:
1 | Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]] |
Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.
Example 1:
1 | Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] |
Example 2:
1 | Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]] |
You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
1 | Input: n = 2 |
Example 2:
1 | Input: n = 3 |
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).
How many possible unique paths are there?
Example 1:
1 | Input: m = 3, n = 7 |
Example 2:
1 | Input: m = 3, n = 2 |
Example 3:
1 | Input: m = 7, n = 3 |
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start times.
Example 1:
1 | Input: intervals = [[1,3],[6,9]], newInterval = [2,5] |
Example 2:
1 | Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] |
Example 3:
1 | Input: intervals = [], newInterval = [5,7] |
Example 4:
1 | Input: intervals = [[1,5]], newInterval = [2,3] |
Example 5:
1 | Input: intervals = [[1,5]], newInterval = [2,7] |