自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 《算法概论》习题8.9 碰撞集

题目:   在碰撞集(HITTING SET)问题中,给定一组集合{S1,S2,...,Sn}\{S_1,S_2,...,S_n\}和预算bb,我们希望求一个与所有的SiS_i相交且规模不超过bb的集合HH,当然,前提是这样的集合确实存在。换句话说,我们希望对所有的ii满足H∩Si≠∅H∩S_i≠\emptyset。   请证明该问题是NP-完全的。证明:   可将顶点覆盖问题归约到碰撞集问题

2016-12-14 00:32:36 825

原创 《算法概论》习题8.19 风筝图

题目:  若有一个图,其顶点数为偶数(比如2n),且其中的n个顶点构成一个团,其余的n个顶点则有一条称为“尾巴”的路径连接,尾巴的某个端点与团中一个顶点相连,这样的图称为“风筝图”。现给定一个图G和目标g,风筝图问题的目标是求出该图的一个包含2g个顶点的风筝子图。请证明该问题是NP-完全的。证明:  我们可以将团问题归约到风筝图问题。团问题的目标是求出某图的一个包含g个顶点的完

2016-12-04 20:06:42 619

原创 40. Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina

2016-12-04 00:37:37 243

原创 39. Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb

2016-12-04 00:03:29 253

原创 338. Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5

2016-12-01 13:30:43 227

原创 62 & 63. Unique Paths I & II

62. Unique Paths:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is

2016-11-03 16:40:02 321

原创 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,2,1] ha

2016-11-02 20:17:10 188

原创 312. Burst Balloons

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[le

2016-10-27 19:09:36 319

原创 116. Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.

2016-10-17 11:16:44 198

原创 199. Binary Tree Right Side View

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1

2016-10-11 13:37:43 255

原创 22. Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())

2016-10-05 12:22:10 202

原创 3. Longest Substring Without Repeating Characters

题目:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the an

2016-09-26 17:27:30 279

原创 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

2016-09-14 00:34:22 173

原创 43. Multiply Strings

先上题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input stri

2016-09-13 13:05:31 191

原创 167. Two Sum II - Input array is sorted

题目:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the t

2016-09-06 22:02:18 207

原创 240. Search a 2D Matrix II

运用了递推的方法。对于这样一个矩阵的任一子块,它的最小值总是在左上角,最大值总是在右下角,那么首先从对角线上的元素和target一个个比较,直到找到一个比target大的元素,以这个元素的左边和上边为界,将矩阵分成四个部分,则左上部分中的元素一定比target小,右下部分中的元素一定比target大,因此只需考虑左下和右上部分的元素。将左下和右上部分重复上述步骤,最后就可以判断矩阵是否存在

2016-09-06 21:42:44 242

空空如也

空空如也

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

TA关注的人

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