- 博客(23)
- 收藏
- 关注
原创 Prove the EXACT 4SAT is NP-complete.
题目:8.8. In the EXACT 4SAT problem, the input is a set of clauses, each of is a disjunction of exactly four literals, and such that each variables occurs at most once in each clause. The goal is to f
2017-07-10 18:04:16
627
原创 623. Add One Row to Tree(Difficulty: Medium)
题目:Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1.The adding rule is: given a po
2017-06-18 23:57:26
314
原创 287. Find the Duplicate Number
题目:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate n
2017-06-11 17:57:19
177
原创 521.Longest Uncommon Subsequence I
题目:Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of thes
2017-06-04 11:35:37
268
原创 557. Reverse Words in a String III
题目:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCo
2017-05-27 15:08:17
215
原创 516. Longest Palindromic Subsequence
题目:Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible longe
2017-05-20 10:00:43
268
原创 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,0
2017-05-13 10:47:22
151
原创 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 adjac
2017-05-03 00:21:59
146
原创 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-05-02 23:05:28
140
原创 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 th
2017-04-25 20:29:50
311
原创 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?Note: Given n will
2017-04-25 19:55:42
148
原创 452. Minimum Number of Arrows to Burst Balloons
题目:There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal,
2017-04-22 00:36:38
192
原创 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 (i
2017-04-17 23:04:38
147
原创 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 of a c
2017-04-12 15:21:35
176
原创 100. Same Tree
题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思路:
2017-04-08 09:37:20
185
原创 111. Minimum Depth of Binary Tree
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.解题思路:类似求最大深度的求解,采用递归算法。
2017-04-08 09:24:13
172
原创 113. Path Sum II
题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5
2017-04-02 10:44:15
160
原创 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum
2017-04-02 10:17:44
152
原创 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.解题思路:决定采用递归算法来解决这个问题,结束条件是当树为空时,高度
2017-03-26 10:17:41
156
原创 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 16:22:09
194
原创 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,-1,
2017-03-11 11:53:27
133
原创 169. Majority Element
题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority eleme
2017-03-04 20:19:02
166
原创 Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums
2017-02-26 12:29:06
173
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人