自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 算法概论 习题8.20

本篇为算法课期末作业。题目是8.20.原题:在一个无向图G=(V,E)中,我们称为一个占优集,是指每个都属于D或者D中一个节点为邻。在占优集问题中,输入为一个图和预算b,目标是求图的一个规模不超过b的控制集——如果该集存在。证明该问题是NP-完全的。解答:可以将顶点覆盖问题归约到支配集问题。若要在图G(V, E)中求得不大于b的一个顶点覆盖,可以先对图G 做一个预处理:对每条边

2017-07-13 18:07:12 347

原创 134. Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2017-06-20 23:30:46 273

原创 542. 01 Matrix

Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.Example 1: Input:0 0 00 1 00 0 0Output:0 0 00 1 00

2017-06-20 22:59:39 298

原创 133. Clone Graph(DFS)

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each

2017-06-20 19:04:03 268

原创 210. Course Schedule II(DFS)

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 expressed as

2017-06-17 11:49:38 348

原创 388. Longest Absolute File Path

原题过长就不拷过来了,题目要求是找出文件系统中的最长绝对路径原题地址:https://leetcode.com/problems/longest-absolute-file-path/#/description输入的是一个字符串,如字符串"dir\n\tsubdir1\n\tsubdir2\n\t\tfile.txt"表示如下的文件系统:dirsubdir1subdir2f

2017-06-10 19:02:29 326

原创 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-06-10 18:34:52 165

原创 23. Merge k Sorted Lists

原本想找一篇与分治策略有关的题目,便搜索了merge类的题目挑一篇做。题目是Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.大意是将K个已经排好序的链表合并成一个链表。一开始打算运用分治法将其一分二,二分四分成n个基本子问题来求解,但由于链

2017-06-04 22:11:35 200

原创 找出数组中唯二出现一次的数

原题取自https://leetcode.com/problems/single-number-iii/?tab=Description题目要求找出数组中唯二出现一次的数,其余数均只出现两次。 要求做到算法的时间复杂度为O(n)解题最直接的方法是计算出数组中每个数出现的次数,然后取其中出现一次的,但其算法复杂度不满足题目要求这里采用异或计算的方法来求解由于 A ^A = 0,,A

2017-02-26 13:46:29 784

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除