自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法作业:证明题(5)-- 8.12

问题摘要:证明如下问题是NP-完全问题,给定一个无向图G=(V,E)和整数k,求G中一个规模为k的团以及一个规模为k的独立集证明:a)对于团,因为对于V的子集V’,其每一对节点是由边集一条边相连,则团为G完全子图。又对于一个给定图G,对于顶点子集V’的任一对顶点(u,v),判断其是否属于E,可在多项式事件确定V’是否为团设φ= C1∧C2∧C3...∧Ck为3-CNF中一个

2017-07-06 22:16:06 696

原创 算法作业:证明题(4)-- 8.12

问题陈述:证明:a)∵给定一个图G的待定生成树,遍历生成树的每一个节点,检查每个点的度数是否小于等于k,可判定其是否满足k-生成树,判定过程时间复杂度O(V)∴ k-生成树问题是一个搜索问题b) ∵需要找到生成的树是否符合要求,检查需要遍历生成树的每一个节点,检查每个点的度数,这一步是时间复杂度是多项式,为V+E     ∴k-生成树为NP问题∵通过Rudr

2017-07-06 20:42:05 265

原创 算法作业HW30:LeetCode 235. Lowest Common Ancestor of a Binary Search Tree

Description:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. Note:According to the definition of LCA on Wikipedia: “The

2017-07-06 20:34:07 182

原创 算法作业HW29:LeetCode 219. Contains Duplicate II

Description:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array  Note:such that nums[i] = nums[j] and the absolu

2017-07-06 20:23:57 238

原创 算法作业HW28:LeetCode 100. Same Tree

Description:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the

2017-07-06 20:11:42 202

原创 算法作业HW27:LeetCode 28. Implement strStr()

Description:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Note:无S

2017-07-06 19:58:00 177

原创 算法作业:证明题(3)-- 8.10

问题描述:证明:a)b)使g=|V|-1,可得到一个Rudrata路径c)让g表示为子句的总数可得d)使a*(a-1)/2 = b,这时候可成最大团问题,因为这使得a个顶点两两之间相互连接e)要成最大独立子集问题,只需使b=0f)对应了最小顶点集覆盖的推广g)

2017-07-06 01:38:03 239

原创 算法作业HW26:LeetCode 27. Remove Element

Description:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with

2017-07-06 00:45:40 206

原创 算法作业HW25:LeetCode 26. Remove Duplicates from Sorted Array

Description:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this

2017-07-06 00:45:29 140

原创 算法作业:证明题(2)-- 8.8

问题描述:证明:

2017-07-04 20:41:48 331

原创 算法作业:证明题(1)-- 8.3

题目描述:证明:∵STINGY SAT的解已知是在多项式时间内可验证∴STINGY SAT是属于NP问题∵通过将k设定为所有变量的总数,就可以把SAT 规约到STINGY SAT问题∴STINGY SAT也为NP完全问题

2017-07-04 20:39:08 241

原创 算法作业HW24:LeetCode 24 Submission Details

Description:Given a linked list, swap every two adjacent nodes and return its head. Note:For example,Given 1->2->3->4, you should return the list as 2->1->4->

2017-07-04 19:56:08 194

原创 算法作业HW23:LeetCode 31 Next Permutation

Description:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange

2017-07-04 19:55:17 202

原创 算法作业HW22:LeetCode29 Divide Two Integers

Description:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT. Note:NoneSolution:

2017-07-03 20:43:50 273

原创 算法作业HW21:LeetCode 18 4Sum

Description:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

2017-07-03 19:57:13 198

原创 算法作业HW20 202. Happy Number

Description:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number

2017-06-25 11:57:01 182

原创 算法作业HW19 130. Surrounded Regions

Description:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.

2017-06-25 11:12:47 296

原创 算法作业HW18:LeetCode102 Binary Tree Level Order Traversal

Description:  Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).Note:For example:Given binary tree [3,9,20,

2017-06-25 11:04:39 284

原创 算法作业HW17:LeetCode101 Symmetric Tree

Description:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric:  Note:

2017-06-25 10:52:30 207

原创 算法作业HW16:LeetCode121 Best Time to Buy and Sell Stock

Description:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of

2017-06-12 09:31:42 208

原创 算法作业HW15:LeetCode187 Repeated DNA Sequences

Description:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences wi

2017-06-06 10:20:32 331

原创 算法作业HW14:Leetcode20 Valid Parentheses

Description:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.Note: The brackets must close in the correct order, "()"

2017-05-23 01:10:52 221

原创 算法作业HW13:Leetcode96 Unique Binary Search Trees

Description:Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?Note: For example,Given n = 3, there are a total of 5 unique BST's. 1

2017-05-22 01:31:37 192

原创 算法作业HW11:Leetcode90 Path Sum

Description:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:Given the below

2017-05-22 00:21:04 176

原创 算法作业HW12:Leetcode94 Sum Root to Leaf Numbers

Description:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number

2017-05-22 00:20:55 307

原创 算法作业HW10:Leetcode92 Reverse Linked List II

Description:Reverse a linked list from position m to n. Do it in-place and in one-pass.Note:For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.

2017-05-07 19:24:36 227

原创 算法作业HW9:LeetCode93 Restore IP Addresses

Description:Given a string containing only digits, restore it by returning all possible valid IP address combinations.Note:For example:Given "25525511135",return ["255.255.11.135

2017-05-07 16:46:15 220

原创 算法设计与分析HW8:LeetCode71.Simplify Path

Description:Given an absolute path for a file (Unix-style), simplify it.Note:For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Solutio

2017-04-25 00:24:59 346

原创 算法设计与分析HW7:LeetCode56.Merge Intervals

Description:  Given a collection of intervals, merge all overlapping intervals.  For example,Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. Solution: 

2017-04-17 02:10:45 328

原创 算法设计与分析 HW6:LeetCode 54

Description:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Note:For example,Given the following matrix:[ [ 1, 2, 3 ]

2017-04-10 19:32:56 343

原创 算法设计与分析HW5:LeetCode77

Description:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.Note: For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4],

2017-03-27 01:17:17 260

原创 算法设计与分析HW4:LeetCode5

Description:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Note: “aba” is also a valid answer when you input "

2017-03-20 12:06:14 294

原创 算法设计与分析HW3:LeetCode3

Description:  Given a string, find the length of the longest substring without repeating characters.Note:  Note that the answer must be a substring,not asubsequence.Sol

2017-03-13 19:49:19 337

原创 算法设计与分析HW2:LeetCode35

Description:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplic

2017-03-06 18:43:27 266

原创 算法设计与分析HW1:LeetCode7

Description:Reverse digits of an integer.Example 1:Input:123Output:321Example 2:Input:-123Output:-321Note:The input is assumed to be a 32-bit signed integer. Your functio

2017-02-28 12:07:29 465

空空如也

空空如也

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

TA关注的人

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