- 博客(19)
- 收藏
- 关注
原创 NP完全问题——证明EXACT 4SAT是NP完全问题
8.8In the EXACT 4SAT problem, the input is a set of clauses, each of which is a disjunction of exactly four literals, and such that each variable occurs at most once in each clause. The goal is to
2017-07-11 16:46:21
506
原创 等价二叉树
题目:两个二叉树结构相同,且对应结点的值相同,我们称这两个二叉树等价. 例如:以下两个二叉树等价 1 1 / \ / \ 2 3 2 3而以下两个则不等价 1 1 / \ / \ 2
2017-06-14 23:12:57
404
原创 会议安排
题目:N个会议要同时举行,参会人数分别为A[0], A[1], ..., A[N-1]. 现有M个会议室,会议室可容纳人数分别为B[0], B[1], ..., B[M-1]. 当A[i] 1 请为下面的Solution类实现解决上述问题的函数assignConferenceRoom. 函数参数A和B的意义如上,返回值为最多可安排的会议数. class Solut
2017-06-14 23:11:07
378
原创 函数求值
题目:定义超级和函数F如下:F(0, n) = n,对于所有的正整数n..F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n. 请实现下面Solution类中计算F(k, n)的函数(1 class Solution {public: int F(int k, in
2017-06-14 23:07:34
776
原创 486. Predict the Winner
486. Predict the WinnerDescriptionHintsSubmissionsSolutionsTotal Accepted: 10743 Total Submissions: 24072 Difficulty: MediumContributors: sameer13Given an
2017-06-12 21:42:08
210
原创 377. Combination Sum IV
Total Accepted: 33521 Total Submissions: 80346 Difficulty: MediumContributor: LeetCodeGiven an integer array with all positive numbers and no duplicates, find the number of possible combin
2017-05-18 16:54:26
211
原创 338. Counting Bits
Total Accepted: 74486 Total Submissions: 123045 Difficulty: MediumContributor: LeetCodeGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the
2017-05-15 14:20:27
193
原创 494. Target Sum
Total Accepted: 16739 Total Submissions: 38242 Difficulty: MediumContributors: kevin.xinzhao@gmail.comYou are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now y
2017-05-09 17:02:25
202
原创 70. Climbing Stairs
题目:Total Accepted: 166090 Total Submissions: 422448 Difficulty: EasyContributor: LeetCodeYou are climbing a stair case. It takes n steps to reach to the top.Each time you can eit
2017-04-25 21:53:11
348
原创 392. Is Subsequence
题目:392. Is SubsequenceTotal Accepted: 28646 Total Submissions: 64661 Difficulty: MediumContributor: LeetCodeGiven a string s and a string t, check if s is subsequence of t.Yo
2017-04-20 17:20:05
213
原创 435. Non-overlapping Intervals
题目:435. Non-overlapping IntervalsTotal Accepted: 10154 Total Submissions: 25196 Difficulty: MediumContributors: love_FawnGiven a collection of intervals, find the minimum numbe
2017-04-20 16:22:27
298
原创 452. Minimum Number of Arrows to Burst Balloons
题目:452. Minimum Number of Arrows to Burst BalloonsAdd to ListDescriptionHintsSubmissionsSolutionsTotal Accepted: 9905Total Submissions: 22906Difficulty: Med
2017-04-18 14:17:57
244
原创 417. Pacific Atlantic Water Flow
题目:417. Pacific Atlantic Water FlowAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 11498Total Submissions: 34789Difficulty: MediumContributor: Lee
2017-04-10 00:15:44
234
原创 207. Course Schedule
207. Course ScheduleAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 73976 Total Submissions: 238137Difficulty: Medium Contributors: AdminThere
2017-03-27 19:02:06
290
原创 200. Number of Islands
题目:200. Number of IslandsAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 94284Total Submissions: 284244Difficulty: MediumContributors: AdminGi
2017-03-19 16:24:29
296
原创 215. Kth Largest Element in an Array
题目:求出数组中第K大元素(指数组排序后的第K大的元素,不是第K个不同的元素)解题思路:本题的解法采用类似快速排序的分治算法。在快排算法中,我们需要选择一个pivot元素并将数组分为三个部分:大于pivot,等于pivot,小于pivot。我们通常使用快排来进行从小到大的排序,但现在只需要对代码稍微做一些修改就能够进行从大到小的排序,将比pivot大的元素放在pivot
2017-03-12 16:01:32
326
原创 240. Search a 2D Matrix II
题目:给出一个每行从左到右递增且每列从上到下递增的二维数组和一个整数,在二维数组中搜索这个数组。解题思路:本题可以采用分治的算法。从二维数组最右上角的元素开始查找,若这个数与target相等,则找到。若这个数比target小,由于这个数是这一整行最大的数,则可知这一整行都比target要小,因此可以删除这一整行。若这个数比target要大,由于这个数是这一整列最小的数,则可知这一整列都
2017-03-02 16:53:38
245
原创 209. Minimum Size Subarray Sum
题意:给定一个序列和一个正整数s,要求找出一个最短的子序列,它的各位之和大于等于正整数s,并返回这个子序列的长度。解题思路:要找出符合特定要求的一个子序列,可以将问题拆分。首先子序列的首位可以是给出的序列的任一位,因此可以用一个循环来遍历序列的每一位,接下来在循环的每一步中找出 以数组的某一位为首位的并且符合要求(即sum>s)的最短子序列,然后使用打擂台的方式找出符合要求的最短子序列
2017-02-26 14:50:06
212
原创 495. Teemo Attacking
分析题目之后发现本题的解题思路可以是先求出数组相邻两次毒药的时间差,如果这个差值比duration要大,则在总时间上加上duration的值。若差值小于等于duration,则意味着上一次毒药效果还没发挥完就又被毒了一次,因此上一次毒药的作用时间为两次毒药的时间差,即在总时间上加上这个时间差。根据此思路写出以下代码:
2017-02-24 19:20:50
313
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅