自定义博客皮肤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)
  • 收藏
  • 关注

原创 [算法作业] Chapter 8 NP-complete problems 课后习题部分证明

【预备知识】将A问题规约到B问题:A -> B,即A可以转化为B的一个实例。如果B在多项式时间内有解,那么A在多项式时间内也有解。如果A是NPC问题,那么B也是NPC问题。8.3     STINGY SAT is the following problem: given a set of clauses (each a disjunction of literal

2017-07-02 16:06:13 712

原创 LeetCode----406(M)、392(M)

406. Queue Reconstruction by HeightSuppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and 

2017-07-04 20:57:30 231

原创 LeetCode----240. Search a 2D Matrix II (M)

1 题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Intege

2017-06-25 20:46:44 218

原创 LeetCode----241. Different Ways to Add Parenthese(M)分治

1 题目Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Exam

2017-06-25 14:36:03 248

原创 Sicily 算法模拟题 1001

1001 函数求值定义超级和函数F如下:F(0, n) = n,对于所有的正整数n..F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n. 请实现下面Solution类中计算F(k, n)的函数(1  class Solution {public:       int F(int k

2017-06-24 16:26:11 233

原创 LeetCode----521(E)、172(E)、26(E)

521. Longest Uncommon Subsequence I172. Factorial Trailing Zeroes26. Remove Duplicates from Sorted Array

2017-06-11 10:52:18 228

原创 LeetCode----537. Complex Number Multiplication

1 题目Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i",

2017-06-04 13:39:13 231

原创 【greedy】LeetCode----455. Assign Cookies

题目Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum siz

2017-05-29 14:11:45 338

原创 【BFS】Leetcode---111(E)、515(M)、542(M)

复习一下广度优先搜索BFS111. Minimum Depth of Binary Tree515. Find Largest Value in Each Tree Row 542. 01 Matrix

2017-05-21 22:37:33 219

原创 LeetCode----128. Longest Consecutive Sequence(H)

1 题目Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,

2017-05-14 11:07:53 228

原创 LeetCode----486. Predict the Winner 动态规划

最近在整理课本第六章动态规划的课后习题,就顺便找leetcode上的题目做啦,顺便复习。。1 题目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

2017-05-05 20:51:24 1161

原创 LeetCode----516. Longest Palindromic Subsequence(M) 动态规划

1 题目求字符串的最长回文子序列长度Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4O

2017-05-01 20:49:56 333 1

原创 LeetCode----312. Burst Balloons(H) 动态规划

1 题目Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooni you will get

2017-04-24 00:28:16 443

原创 LeetCode----72. Edit Distance(H) 动态规划

题目        还是动态规划,学到这里算是有了一点感觉,这个题也算是整理一下课堂的学习吧~        点击打开链接        编辑距离,也就是求两个字符串之间的最短距离,应用实例如搜索引擎(提示你查找的是不是“xxxx”)、医学信息工程的基因问题研究等。分析       字符串:x[1...m] 和y[1...n]       E[i

2017-04-16 10:48:11 348

原创 LeetCode---300. Longest Increasing Subsequence (M)

这星期老师刚好讲到动态规划,讲了最长递增子序列(LIS)问题,于是在LeetCode中找了该题来做1 题目     求最长递增子序列长度。即在一个给定的数值序列中,找到一个子序列,使得这个子序列元素的数值依次递增,并且这个子序列的长度尽可能地大。最长递增子序列中的元素在原序列中不一定是连续的。这是一道动态规划的典型问题     点击打开链接2 分析     该题

2017-04-09 22:31:15 200

原创 LeedCode----169. Majority Element(M)

1 题目    寻找数组中次数多于⌊n/2⌋次的元素,即主元素/众数    题目链接:点击打开链接2 思路和实现   (1) 分治算法:             将数组分为左右两边,分别找出左右两边的主元素并计算其出现的频率,对比频率找出每个小问题的主元素,递归调用完成算法。             class Solution {public: int

2017-04-02 22:29:34 278

原创 LeetCode----513. Find Bottom Left Tree Value (M)

题目点击打开链接给定一个二叉树,找出最左边的DFS,即返回最大深度BFS,保存每层的第一个值,最后一层的值即为所求

2017-03-23 21:38:43 191

原创 LeetCode----Minesweeper (M)

1 题目分析    题目链接:点击打开链接    题目就是小时候玩过的扫雷游戏,总结一下规则,在本题中规则也就是思路了:    ① 扫到M → 用X替换M,游戏结束(返回board)    ② 扫到E → 计算其周围(8个方向)的M的个数Mcount                           → Mcount > 0,用Mcount替换E

2017-03-19 15:02:20 313

原创 LeetCode----Maximum Subarray (E) / Maximum Product Subarray (M)

Maximum Subarray (E) Maximum Product Subarray (M)C++

2017-03-10 15:08:34 243

原创 LeetCode---Add Two Numbers

LeetCode---Add Two Numbers Difficulty:MediumC++

2017-03-01 21:14:45 284

原创 LeetCode----Two Sum

很久没有做过算法题了,脑子也不太好用了,趁着算法课的机会学习一下,这周选了最简单的第一题来做。LeetCode Two Sum,题目如下所示:由于一开始也没有特别多的思路,秉承着先做到再做好的信仰,用了两种方法:(1)一开始使用了最暴力的方法,也就是使用两个循环,显然O(N2)的时间复杂度使得算法超时了。(2)先对数组进行排序,由于排序会使位置发生改变,因此使用结构体记录下数值

2017-02-26 22:36:20 256

空空如也

空空如也

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

TA关注的人

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