Problem
Given a collection of intervals, merge all overlapping intervals.
Example 1:
1 |
|
Example 2:
1 |
|
NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
Given a collection of intervals, merge all overlapping intervals.
Example 1:
1 |
|
Example 2:
1 |
|
NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
Given an array of non-negative integers, 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 |
|
Example 2:
1 |
|
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
Example 1:
1 |
|
Example 2:
1 |
|
Given an integer array nums
, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Example:
1 |
|
Follow up:
If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return the number of distinct solutions to the n-queens puzzle.
Example:
1 |
|
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle.
Each solution contains a distinct board configuration of the n-queens’ placement, where 'Q'
and '.'
both indicate a queen and an empty space respectively.
Example:
1 |
|
Implement pow(x, n), which calculates $x$ raised to the power $n (x^n)$.
Example 1:
1 |
|
Example 2:
1 |
|
Example 3:
1 |
|
Note:
Given an array of strings, group anagrams together.
Example:
1 |
|
Note:
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
1 |
|
Example 2:
1 |
|
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
Example:
1 |
|