Restore IP Addresses
Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations. For example:123Given "25525511135",return ["255.255.11.13
Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations. For example:123Given "25525511135",return ["255.255.11.13
Reverse Linked List IIReverse a linked list from position m to n. Do it in-place and in one-pass. For example:123Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2-&
Subsets IIGiven a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example:If nums = [1,2,2], a
Partition ListGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the node
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example:12Given 1->2->3-
Search in Rotated Sorted Array II Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose an array sorted in a
Remove Duplicates from Sorted Array IIFollow up for “Remove Duplicates”:What if duplicates are allowed at most twice? For example:123Given sorted array nums = [1,1,1,2,2,3],Your function should retur
Word SearchGiven a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or v
CombinationsGiven two integers n and k, return all possible combinations of k numbers out of 1 … n. For example:If n = 4 and k = 2, a solution is: 12345678[ [2,4], [3,4], [2,3], [1,2], [1,3], [
Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the
Search a 2D MatrixWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first i
Set Matrix ZeroesGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight forward solution using O(mn) space is pro
Simplify PathGiven an absolute path for a file (Unix-style), simplify it. For example:12path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" 提
Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either do
Unique Paths IIFollow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively
Unique PathsA 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