![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法设计作业
文章平均质量分 76
fredahu
这个作者很懒,什么都没留下…
展开
-
240. Search a 2D Matrix II
题目: 给出一个每行从左到右递增且每列从上到下递增的二维数组和一个整数,在二维数组中搜索这个数组。 解题思路: 本题可以采用分治的算法。从二维数组最右上角的元素开始查找,若这个数与target相等,则找到。若这个数比target小,由于这个数是这一整行最大的数,则可知这一整行都比target要小,因此可以删除这一整行。若这个数比target要大,由于这个数是这一整列最小的数,则可知这一整列都原创 2017-03-02 16:53:38 · 204 阅读 · 0 评论 -
NP完全问题——证明EXACT 4SAT是NP完全问题
8.8 In 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 · 407 阅读 · 0 评论 -
等价二叉树
题目: 两个二叉树结构相同,且对应结点的值相同,我们称这两个二叉树等价. 例如:以下两个二叉树等价 1 1 / \ / \ 2 3 2 3 而以下两个则不等价 1 1 / \ / \ 2原创 2017-06-14 23:12:57 · 345 阅读 · 0 评论 -
函数求值
题目: 定义超级和函数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 · 695 阅读 · 0 评论 -
会议安排
题目: 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 · 316 阅读 · 0 评论 -
494. Target Sum
Total Accepted: 16739 Total Submissions: 38242 Difficulty: MediumContributors: kevin.xinzhao@gmail.com You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now y原创 2017-05-09 17:02:25 · 145 阅读 · 0 评论 -
70. Climbing Stairs
题目: Total Accepted: 166090 Total Submissions: 422448 Difficulty: EasyContributor: LeetCode You 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 · 202 阅读 · 0 评论 -
338. Counting Bits
Total Accepted: 74486 Total Submissions: 123045 Difficulty: MediumContributor: LeetCode Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the原创 2017-05-15 14:20:27 · 144 阅读 · 0 评论 -
392. Is Subsequence
题目:392. Is Subsequence Total Accepted: 28646 Total Submissions: 64661 Difficulty: MediumContributor: LeetCode Given a string s and a string t, check if s is subsequence of t. Yo原创 2017-04-20 17:20:05 · 166 阅读 · 0 评论 -
435. Non-overlapping Intervals
题目: 435. Non-overlapping Intervals Total Accepted: 10154 Total Submissions: 25196 Difficulty: MediumContributors: love_Fawn Given a collection of intervals, find the minimum numbe原创 2017-04-20 16:22:27 · 246 阅读 · 0 评论 -
452. Minimum Number of Arrows to Burst Balloons
题目: 452. Minimum Number of Arrows to Burst Balloons Add to List DescriptionHintsSubmissionsSolutions Total Accepted: 9905Total Submissions: 22906Difficulty: Med原创 2017-04-18 14:17:57 · 197 阅读 · 0 评论 -
417. Pacific Atlantic Water Flow
题目: 417. Pacific Atlantic Water Flow Add to List DescriptionSubmissionsSolutions Total Accepted: 11498Total Submissions: 34789Difficulty: MediumContributor: Lee原创 2017-04-10 00:15:44 · 188 阅读 · 0 评论 -
215. Kth Largest Element in an Array
题目: 求出数组中第K大元素(指数组排序后的第K大的元素,不是第K个不同的元素) 解题思路: 本题的解法采用类似快速排序的分治算法。 在快排算法中,我们需要选择一个pivot元素并将数组分为三个部分:大于pivot,等于pivot,小于pivot。 我们通常使用快排来进行从小到大的排序,但现在只需要对代码稍微做一些修改就能够进行从大到小的排序,将比pivot大的元素放在pivot原创 2017-03-12 16:01:32 · 234 阅读 · 0 评论 -
207. Course Schedule
207. Course Schedule Add to List DescriptionSubmissionsSolutions Total Accepted: 73976 Total Submissions: 238137 Difficulty: Medium Contributors: Admin There原创 2017-03-27 19:02:06 · 236 阅读 · 0 评论 -
200. Number of Islands
题目: 200. Number of Islands Add to List DescriptionSubmissionsSolutions Total Accepted: 94284Total Submissions: 284244Difficulty: MediumContributors: Admin Gi原创 2017-03-19 16:24:29 · 245 阅读 · 0 评论 -
209. Minimum Size Subarray Sum
题意: 给定一个序列和一个正整数s,要求找出一个最短的子序列,它的各位之和大于等于正整数s,并返回这个子序列的长度。 解题思路: 要找出符合特定要求的一个子序列,可以将问题拆分。首先子序列的首位可以是给出的序列的任一位,因此可以用一个循环来遍历序列的每一位,接下来在循环的每一步中找出 以数组的某一位为首位的并且符合要求(即sum>s)的最短子序列,然后使用打擂台的方式找出符合要求的最短子序列原创 2017-02-26 14:50:06 · 166 阅读 · 0 评论 -
495. Teemo Attacking
分析题目之后发现本题的解题思路可以是先求出数组相邻两次毒药的时间差,如果这个差值比duration要大,则在总时间上加上duration的值。若差值小于等于duration,则意味着上一次毒药效果还没发挥完就又被毒了一次,因此上一次毒药的作用时间为两次毒药的时间差,即在总时间上加上这个时间差。根据此思路写出以下代码:原创 2017-02-24 19:20:50 · 259 阅读 · 1 评论 -
486. Predict the Winner
486. Predict the Winner DescriptionHintsSubmissionsSolutions Total Accepted: 10743 Total Submissions: 24072 Difficulty: MediumContributors: sameer13 Given an原创 2017-06-12 21:42:08 · 158 阅读 · 0 评论