自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法概论第八章练习题 8.10

题目:利用推广的方法证明NP-完全性。对以下每个问题,请通过证明它是本章某个NP-完全问题的推广说明它是NP-完全的。(a)子图同构:给定两个作为输入的无向图G和H,判断G是否与H的某个子图同构,且如果是,返回由V(G)到V(H)的相关映射。 (b)最长路径:给定图G和整数g,求G中一条长为g的简单路径。 (c)最大SAT:给定一个CNF公式和整数g,求满足其中至少g个

2017-07-09 10:38:07 261

原创 算法概论第八章练习题 8.14

题目:证明如下问题是NP-完全的:给定一个无向图G=(V, E)和整数k,求G中一个规模为k的集以及一个规模为k 的独立集。假定他们都是存在的。证明:可以将最大独立集问题规约到此问题,比如若要求任意图G(V, E)中存在大小为d的独立集,可以令G1 = G(V, E),再令G2(V,∅)的顶点集与G相同,但是边集为空,也即是各个顶点相互独立。于是G1与G

2017-07-09 10:36:42 505

原创 算法概论第八章练习题 8.19

题目:所谓风筝图是这样的,其定点数为偶数,比如2n,且其中的n个顶点构成一个团,其余的n个顶点则由一条称为“尾巴”的路径连接,尾巴的某个与团中一个顶点相连。给定一个图和目标g,风筝图问题要求该图的一个包含2个顶点的风筝子图。请证明该问题是NP-完全的。证明:这个团问题实际上可以归类成一种kite问题,给定一个图G,和目标g,求一个有g个顶点的完全

2017-07-09 10:19:12 226

原创 算法概论第八章练习题 8.3

题目:STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an assig

2017-07-14 19:40:48 544

原创 321. Create Maximum Number

Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k  from digits of the two. The relative order of the digits from the same array mus

2017-07-14 18:26:38 209

原创 329. Longest Increasing Path in a Matrix

Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside

2017-07-14 17:49:05 177

原创 94. Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].题目的意思是中序遍历二叉树,

2017-07-14 17:22:13 159

原创 99. Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.一棵二叉树原本是二叉搜索树,但是其中有两个节点调换了位置,要求恢复原来的二叉搜索树。二叉搜索树的中序遍历就是升序序列。因此不

2017-07-14 17:14:24 280

原创 413. Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:

2017-07-09 09:40:42 138

原创 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,000) strin

2017-07-09 08:50:31 156

原创 322. Coin Change

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of mone

2017-06-14 00:09:08 136

原创 403. Frog Jump

A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list of s

2017-06-13 23:56:29 231

原创 517.Super Washing Machines

You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.For each move, you could choose any m (1 ≤ m ≤ n) washing machines, and passone dress of

2017-05-22 21:27:45 295

原创 467. Unique Substrings in Wraparound String

Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", sos will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Now we have

2017-05-15 20:20:51 197

原创 357. Count Numbers with Unique Digits

Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, excludin

2017-05-08 12:11:06 151

原创 45. Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is

2017-05-01 20:57:02 206

原创 402. Remove K Digits

Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note:The length of num is less than 10002 and will

2017-04-24 20:10:24 267

原创 134. Gas Station Add to List

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

2017-04-16 20:21:36 249

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

2017-04-09 16:52:15 150

原创 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-26 17:42:12 159

原创 503. Next Greater Element II

Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first g

2017-03-18 21:58:34 138

原创 496. 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-03-18 17:40:58 172

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

2017-03-12 10:31:42 128

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

2017-03-05 18:42:53 145

原创 237. Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value

2017-03-05 16:28:22 145

原创 292. Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2017-02-26 16:38:07 198

原创 374. Guess Number Higher or Lower

We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is highe

2017-02-26 16:07:35 190

空空如也

空空如也

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

TA关注的人

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