原创 [leetcode] Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each
原创 [leetcode] Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum
原创 [leetcode]Divide two integers
Divide two integers without using multiplication, division and mod operator. 思路:如果循環加除數的話,會超時。所以得加速加的過程,每次二倍得加,如果超了,再縮小
原创 [leetcode] Reverse Linked List ii
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m
原创 [leetcode] Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 思路:雙指針
原创 [leetcode] Remove Duplicates from sorted array II
Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A =
原创 [leetcode] Unique Path II
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would ther
原创 [leetcode] Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you so
原创 [leetcode]Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the origi
原创 [leetcode] Insertion Sort List
Sort a linked list using insertion sort. 思路:思路上和insertion sort一致,需要注意的是,需要判斷前一個元素是否比當前元素大,如果大的話,則需要insertion, 從head開始遍歷
原创 [leetcode] Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,
原创 [leetcode] Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, wi
原创 [leetcode] Rotate Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could
原创 [leetcode] longest substring without repeating characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substri
原创 [leetcode] next permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.