- 博客(28)
- 收藏
- 关注
原创 算法设计与应用基础
242. Valid Anagramiven two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return f
2017-06-23 23:41:51
183
原创 课后习题8.8
首先很显然,EXACT 4SAT属于NP。现在通过将3SAT归约到EXACT 4ASAT来证明后者的NP完全性。对于任意一个3SAT实例,如果某个子句中包含了同一个文字多次,那么可以缩减为一次,如果同时包含了某个变量的肯定及否定,那么可以将这个变量去掉,然后可以再在每个子句中添加一些没用的辅助变量,这样就可以将每个子句所包含的文字数目扩充到四个。这样就将3SAT实例转换成一个EXACT 4SAT问
2017-06-14 22:03:32
343
原创 算法设计与应用基础
234. Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.class Solution {public: bool isPalindrome(ListNode* head) { if(head==NULL||head
2017-06-12 14:06:20
238
原创 算法设计与应用基础
226. Invert Binary TreeInvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1RecursiveTreeNode* inver
2017-06-12 13:38:19
155
原创 算法设计与应用基础
216. Combination Sum IIIFind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set o
2017-06-12 13:06:21
204
原创 算法设计与应用基础
206. Reverse Linked ListReverse a singly linked list.click to show more hints.xWell, since the head pointer may also be modified, we create a new_head that points to it t
2017-06-12 12:34:53
173
原创 算法设计与应用基础
202. Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the numbe
2017-06-10 23:54:39
176
原创 算法设计与应用基础
189. Rotate ArrayRotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].这是一个数组的题目 ,相
2017-06-10 23:36:30
138
原创 算法设计与应用基础
188. Best Time to Buy and Sell Stock IVSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comp
2017-06-10 22:41:38
207
原创 算法设计与应用基础
187.All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA
2017-06-10 22:38:33
281
原创 算法设计与应用基础
179. Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.N
2017-05-16 23:32:41
291
原创 算法设计与应用基础
172. Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.Credits:Special thanks to @ts
2017-05-16 22:55:03
212
原创 算法设计与应用基础
168. Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->
2017-05-16 22:49:22
210
原创 算法设计与应用基础
167. Two Sum II - Input array is sortedGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The functi
2017-05-16 16:13:42
171
原创 算法设计与应用基础
160. Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A:
2017-05-16 16:10:08
160
原创 算法设计与应用基础
155. Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of
2017-05-16 16:06:41
193
原创 算法设计与应用基础
152. Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the con
2017-05-16 16:03:13
308
原创 算法设计与应用基础
150. Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another
2017-05-16 15:57:28
191
原创 算法设计与应用基础
150. Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another
2017-05-03 23:53:12
193
原创 算法设计与应用基础
135. CandyThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child m
2017-05-03 23:50:23
248
原创 算法设计与应用基础
139. Word BreakGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more diction
2017-05-03 23:48:16
154
原创 算法设计与应用基础
118. Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]
2017-04-18 14:40:17
129
原创 算法设计与应用基础
103. Binary Tree Zigzag Level Order TraversalGiven a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level
2017-04-11 11:33:09
190
原创 算法设计与应用基础
39. Combination SumGiven a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same r
2017-03-28 12:48:08
247
原创 算法设计与应用基础
22. Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "
2017-03-20 23:02:15
180
原创 算法设计与应用基础
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of c
2017-03-12 22:35:41
332
原创 算法设计与应用基础
13. Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question
2017-03-05 18:45:52
161
原创 算法设计与应用基础
21.Merge To Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.题解:要合并两个排序好的list。先创一个新的list
2017-02-25 21:34:11
197
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人