原创 Leetcode -- 24. Swap Nodes in Pairs
題目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you s
原创 Leetcode -- 27. Remove Element
題目:Given an array and a value, remove all instances of that value in place and return the new length. Do not alloca
原创 Leetcode -- 22. Generate Parentheses
題目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For exam
原创 Leetcode -- 29. Divide Two Integers
題目:Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT.
原创 Leetcode -- 33. Search in Rotated Sorted Array
題目: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5
原创 LeetCode -- 5. Longest Palindromic Substring
題目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1
原创 Leetcode -- 491. Increasing Subsequences
題目: Given an integer array, your task is to find all the different possible increasing subsequences of the given ar
原创 Leetcode -- 31. Next Permutation
題目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of num
原创 LeetCode -- 53. Maximum Subarray
題目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For ex
原创 凸包(Convex Hull)問題的三種解法: 暴力,Graham Scan,分治
凸包問題描述: 平面上n個點的集合Q的convex hull是一個最小凸多邊形P,Q的點或者在P上或者在P內。凸多邊形P是具有如下性質多邊形:連接P內任意兩點的邊都在P內 暴力法: 思想: 從所有的點中找到y座標最小的點P
原创 Leetcode -- 21. Merge Two Sorted Lists
題目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the
原创 Leetcode -- 35. Search Insert Position
題目: Given a sorted array and a target value, return the index if the target is found. If not, return the index whe
原创 Leetcode -- 26. Remove Duplicates from Sorted Array
題目:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new
原创 Leetcode -- 28. Implement strStr()
題目:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part
原创 最長公共子序列(Longest Common Sequence)
問題的定義: 子序列 X=(A, B, C, B, D, B) Z=(B, C, D, B)是X的子序例 W=(B, D, A)不是X的子序例 公共子序列 Z是序列X與Y的公共子序列如果Z是X的子序也是Y的子序列。 最長