原创 leetcode之Best Time to Buy and Sell Stock && II && III

Best Time to Buy and Sell Stock的原題如下: Say you have an array for which the ith element is the price of a given stock o

原创 leetcode之Scramble String

原題如下: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursiv

原创 leetcode之Anagrams

原題如下: Given an array of strings, return all groups of strings that are anagrams. 不得不說,這道題的題意太模糊了,首先簡單介紹一下Anagram(迴文構詞法)

原创 leetcode之Sqrt(x)

原題如下: Implement int sqrt(int x). Compute and return the square root of x. 普通遍歷方法肯定是超時的,這道題其實是一個有序數列中的查找問題,所以如果能想到這點兒

原创 leetcode之Permutations II

原題如下: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For exam

原创 leetcode之ZigZag Conversion

原題如下: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want

原创 leetcode之Distinct Subsequences

原題如下: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a strin

原创 leetcode之Reverse Nodes in k-Group

原題如下: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the numbe

原创 leetcode之Add Two Numbers

原題如下: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order an

原创 leetcode之Jump Game && Jump Game II

Jump Game的原題如下: Given an array of non-negative integers, you are initially positioned at the first index of the array

原创 leetcode之Merge k Sorted Lists

原題如下: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路一:按照歸併排序的思路

原创 leetcode之Copy List with Random Pointer

原題如下: A linked list is given such that each node contains an additional random pointer which could point to any node

原创 leetcode之Remove Duplicates from Sorted List II

原題如下: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from th

原创 leetcode之Edit Distance

原題如下: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each ope

原创 leetcode之Rotate List

原題如下: Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4