自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 NP完全问题习题证明

NP-完全问题 一、概述 1.1 P问题 如果一个问题可以找到一个能在多项式的时间里解决它的算法,那么这个问题就属于P问题,P(olynominal) 问题。 1.2 NP问题 能在多项式时间内验证给出的一个解的问题属于NP问题,Nondeterministic Polynominal,非确定性多项式问题。 NP 问题不是非 P 类问题,NP问题的另一个定义是,可以在多项式的时间里猜出

2017-06-23 11:43:50 3530

原创 LeetCode 491. Increasing Subsequences

【题目】 Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 . Exampl

2017-06-23 01:18:50 246

原创 LeetCode 153. Find Minimum in Rotated Sorted Array

【题目】 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may

2017-06-22 10:46:30 227

原创 LeetCode 39. Combination Sum and LeetCode 40. Combination Sum II

【题目 LeetCode 39】 Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeat

2017-06-12 14:36:00 222

原创 LeetCode 18. 4Sum and LeetCode 454. 4Sum II

【题目 LeetCode 18】 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-06-06 17:16:48 231

原创 LeetCode 486. Predict the Winner

【题目】 Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a play

2017-05-29 21:12:59 255

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

2017-05-21 19:12:50 188

原创 LeetCode 309. Best Time to Buy and Sell Stock with Cooldown

【题目】 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (

2017-05-15 19:22:11 146

原创 LeetCode 198. House Robber

【题目】 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjace

2017-05-06 15:51:22 157

原创 动态规划(一)

本博客所有问题都可能有多种解法,但这里主要讲解其动态规划的算法 1、最长公共子序列 2、最长公共子串 3、最长递增子序列   最长公共子序列(LCS) 【问题描述】        最长公共子序列,英文缩写为LCS,其定义是,一个序列 S ,如果分别是序列(S1,S2……)的子序列,且是所有符合此条件 序列中最长的,则 S 称为已知序列的最长公共子序列。需要注意的是序列S并

2017-04-30 23:52:49 188

原创 LeetCode 64. Minimum Path Sum

【题目】 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down o

2017-04-23 23:08:45 159

原创 LeetCode 343. Integer Break 题解

【题目】 Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given

2017-04-16 16:06:06 151

原创 LeetCode 376. Wiggle Subsequence 题解

【题目】 A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may b

2017-04-10 22:39:02 229

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

2017-04-03 00:58:32 227

原创 LeetCode 55. Jump Game and 45. Jump Game II 题解

贪心算法 【LeetCode 55. Jump Game】 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

2017-03-26 20:40:13 199

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

2017-03-19 17:21:26 320

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

2017-03-12 12:29:16 664

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

2017-03-05 12:52:54 365

原创 LeetCode 215.Kth Largest Element in an Array O(n)题解

快速选择算法 【题目】 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 =

2017-02-26 13:35:02 504

空空如也

空空如也

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

TA关注的人

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