- 博客(19)
- 收藏
- 关注
原创 【NP-完全问题】课后习题8.3
用SAT问题来规约吝啬SAT问题,若SAT问题有n个变量,那么他就等价于k=n的吝啬SAT问题。由于SAT问题是NP-完全问题,且吝啬SAT问题能在多项式时间里规约成SAT问题,所以吝啬SAT问题是NP-完全问题
2017-07-04 19:47:40
505
原创 【leedcode】 Add to List 617. Merge Two Binary Trees
题目:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new bi
2017-07-01 10:04:54
346
原创 【leedcode】 Add to List 303. Range Sum Query - Immutable
题目:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) ->
2017-06-23 19:56:06
210
原创 【leedcode】392. Is Subsequence
题目:Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000
2017-06-10 21:35:35
206
原创 【leetcode】338. Counting Bits
题目:Total Accepted: 75933Total Submissions: 125118Difficulty: MediumContributor: LeetCodeGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate
2017-06-02 22:18:15
191
原创 【leedcode】198. House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacen
2017-05-27 15:15:56
223
原创 【leedcode】96. Unique Binary Search Trees
题目:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1
2017-05-21 15:37:33
196
原创 【leedcode】70. Climbing Stairs
题目:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?分析:由提议,设f(n)是上n阶台
2017-05-14 12:24:20
159
原创 【leedcode】53. Maximum Subarray
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-
2017-05-07 20:39:34
185
原创 【leedcode】121. Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
2017-05-01 23:38:42
170
原创 【leedcode】122. Best Time to Buy and Sell Stock II
题目:Say 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 complete as many transactions as you like (ie,
2017-04-22 23:59:08
213
原创 【leetcode】455. Assign Cookies
题目:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size
2017-04-15 23:38:54
243
原创 【leetcode】 513. Find Bottom Left Tree Value
题目:Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2
2017-04-09 18:31:12
164
原创 【leedcode】210. Course Schedule II
题目:There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expr
2017-04-01 10:42:33
179
原创 【leedcode】207. Course Schedule
题目:There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expr
2017-03-26 01:29:14
190
原创 【leetcode】399. Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answ
2017-03-19 00:53:44
245
原创 【leetcode】215. Kth Largest Element in an Array
题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return
2017-03-11 14:04:56
162
原创 【LeetCode】315. Count of Smaller Numbers After Self
题目:You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].
2017-03-04 23:27:02
208
原创 【LeetCode】144. Binary Tree Preorder Traversal
题目:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].本题虽然归结为Medium
2017-02-26 13:05:10
234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人