自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法概论8.8

题目:  在精确的4SAT(EXACT 4SAT)问题中,输入为一组子句,每个字句都是恰好4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果该赋值存在。证明精确的4SAT是NP-完全问题。证明:在证明精确的4SAT问题是NP-完全问题前,先得证明其属于NP问题。因为EXACT 4SAT和SAT相同,在多项式时间内可以显然地给出一个解得以验证,所以我

2017-07-14 19:35:02 408

原创 leetcode:K inverse pairs array

Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.We define an inverse pair as following: For ith and jth elem

2017-07-14 19:15:51 472

原创 leetcode:valid square

Given the coordinates of four points in 2D space, return whether the four points could construct a square.The coordinate (x,y) of a point is represented by an integer array with two integers.E

2017-07-14 19:12:19 505

原创 leetcode:Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in

2017-07-14 18:52:06 342

原创 leetcode:Out of Boundary Paths

There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary in four directions (up, down, left, right). However

2017-07-14 18:49:11 355

原创 leetcode: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 y

2017-07-09 11:00:49 285

原创 leetcode: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) str

2017-07-09 10:55:14 266

原创 leetcode: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:24:30 357

原创 leetcode: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 money

2017-06-13 15:39:43 253

原创 动态规划: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:45:43 1201

原创 leetcode: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:32:00 336

原创 leetcode: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 11:31:11 316

原创 leetcode: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:44:02 549

原创 leetcode: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 14:21:43 423

原创 leetcode贪心算法:Gas Station

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:34:07 891

原创 leetcode:Minimum Height Trees

先上题目:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are call

2017-04-10 12:21:38 289

原创 leetcode:path sum:深度优先搜索

leetcode在深度优先算法有2道题目,分别是“path sum”和“path sum2”,思路上是一个顺承的关系。本文借助这2道题目,对树的深度优先搜索进行一个简单的训练。先看第一题:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all t

2017-03-27 15:02:34 551

原创 图的深度广度搜索简单训练:Course Schedule

先看题目:There are a total of n courses you have to take, labeled from 0 ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed

2017-03-20 11:18:09 467

原创 动态规划:Burst Balloons

首先先明白什么是动态规划,引用百度百科的介绍:动态规划算法是五种常见的算法之一,通常用于求解具有某种最优性质的问题。动态规划算法与分治法类似,其基本思想也是将待求解问题分解成若干个子问题。动态规划与其它算法相比,大大减少了计算量,丰富了计算结果,不仅求出了当前状态到目标状态的最优值,而且同时求出了到中间状态的最优值,这对于很多实际问题来说是很有用的。动态规划相比一般算法也存在一定缺点:空间占据过多

2017-03-13 14:58:33 811

原创 分治算法解题:Maximum Subarray

leetcode上的分治算法有这样一道题: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

2017-03-02 15:53:53 1035

原创 leetcode水题:Max Consecutive Ones

首次接触leetcode,于是选了几道水题来试试水,“Max Consecutive Ones”这一道算是想的蛮多的一道题,所以在这里详细记录一下。

2017-02-25 15:34:59 382

空空如也

空空如也

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

TA关注的人

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