記錄: 2017/5

0

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

0

Reverse Linked List II

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-&

0

Subsets II

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

0

Gray Code

Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the seque

0

Partition List

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

0

Remove Duplicates from Sorted List II

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-

0

Search in Rotated Sorted Array II

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

0

Remove Duplicates from Sorted Array II

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

0

Word Search

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

0

Subsets

SubsetsGiven a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example:If nums = [1,2,3], a solution is: 12345678910[ [3],

0

Combinations

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], [

0

Sort Colors

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

0

Search a 2D Matrix

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

0

Set Matrix Zeroes

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

0

Sqrt(x)

Sqrt(x)Implement int sqrt(int x). Compute and return the square root of x. 提示 解題應用 Math 規律觀查 Default:123func mySqrt(x int) int {} 解答思路:這題姑且只用最簡單的方式去解決,當然有人用牛頓法的方法來找出結果,不過一開始我就是只用最

0

Simplify Path

Simplify PathGiven an absolute path for a file (Unix-style), simplify it. For example:12path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" 提

0

Minimum Path Sum

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

0

Unique Paths II

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

0

Unique Paths

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