- 博客(85)
- 收藏
- 关注
原创 leetcode之Interleaving String
原题如下:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbb
2014-10-18 22:40:55
367
原创 leetcode之Two Sum
原题如下:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the
2014-06-10 10:43:24
358
原创 leetcode之Median of Two Sorted Arrays
原题如下:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).这道题muqian
2014-06-10 09:56:03
557
原创 leetcode之Evaluate Reverse Polish Notation
原题如下:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples:
2014-06-09 21:32:33
283
原创 leetcode之Reorder List
原题如下:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reo
2014-06-08 21:09:44
348
原创 leetcode之Sort List
原题如下:Sort a linked list in O(n log n) time using constant space complexity.leetcode上
2014-06-08 11:49:57
346
原创 leetcode之Reverse Words in a String
原题如下:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".这道题的题意很明确,首先想到的是将字符串按空格分割
2014-06-07 22:49:49
354
原创 leetcode之Merge Intervals
原题如下:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].关键还是思路,当理解了
2014-06-07 21:46:26
356
原创 leetcode之Word Break
原题如下:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dic
2014-06-03 22:28:24
398
原创 leetcode之Implement strStr()
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
2014-06-03 19:23:52
398
原创 leetcode之Permutation Sequence
原题如下:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""
2014-06-03 09:40:03
395
原创 leetcode之Maximal Rectangle
原题如下:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.此题s
2014-06-02 17:08:40
515
原创 leetcode之Largest Rectangle in Histogram
原题如下:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram wh
2014-05-30 11:41:55
615
原创 leetcode之Clone Graph
原题如下:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separ
2014-05-28 17:09:24
563
原创 leetcode之Sqrt(x)
原题如下:Implement int sqrt(int x).Compute and return the square root of x.普通遍历方法kendi
2014-05-27 16:33:40
357
原创 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->5->NULL and k = 2,return 4->5->1->2->3->NULL.这道题关键是理解题意,
2014-05-27 14:53:14
355
原创 leetcode之First Missing Positive
原题如下:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and us
2014-05-26 21:05:51
380
原创 leetcode之Scramble String
原题如下:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great /
2014-05-25 22:55:42
406
原创 leetcode之Valid Palindrome
原题如下:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car
2014-05-23 15:36:01
303
原创 leetcode之Best Time to Buy and Sell Stock && II && III
Best Time to Buy and Sell Stock的原题如下:
2014-05-22 23:11:01
421
原创 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 in the list or null.Return a deep copy of the list.
2014-05-22 15:54:10
344
原创 leetcode之Add Two Numbers
原题如下:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i
2014-05-20 22:59:25
271
原创 leetcode之Recover Binary Search Tree
原题如下:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Coul
2014-05-20 21:24:47
396
原创 leetcode之Anagrams
原题如下:Given an array of strings, return all groups of strings that are anagrams.不得不说,这道题的题意太模糊了,
2014-05-20 17:01:04
450
原创 leetcode之ZigZag Conversion
原题如下:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N
2014-05-20 15:56:03
365
原创 leetcode之Merge k Sorted Lists
原题如下:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路一:按照归并排序的思路
2014-05-19 21:34:31
326
原创 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 string is a new string which is formed from the original string by deleting some
2014-05-19 16:45:44
370
原创 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.Each element in the array represents your maximum jump length at that pos
2014-05-19 16:29:54
367
原创 leetcode之Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2014-05-16 11:27:32
334
原创 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 original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.
2014-05-14 20:51:07
233
原创 leetcode之Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2014-05-14 16:14:12
225
原创 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 number of nodes is not a multiple of k then left-out nodes in the end should rema
2014-05-12 19:54:03
265
原创 leetcode之Permutations II
原题如下:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], a
2014-05-08 21:32:53
364
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人