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 |
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] |
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Example 1:
1 | Input: intervals = [[1,3],[2,6],[8,10],[15,18]] |
Example 2:
1 | Input: intervals = [[1,4],[4,5]] |
Given an array of non-negative integers nums, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if you are able to reach the last index.
Example 1:
1 | Input: nums = [2,3,1,1,4] |
Example 2:
1 | Input: nums = [3,2,1,0,4] |