自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 最后的作业——NP完全问题证明

a)子图同构:令G为一个环,环上所有顶点数与H的顶点数相同,如果G是H的同构子图,那么H就包含了一条Rudrata回路,因此,Rudrata回路问题归约到了子图同构问题,因此,子图同构也是NP完全问题b)最长路径问题:令整数g = 图G顶点数 - 1,那么我们找到的就是一条Rudrata路径,因此,Rudrata路径问题归约到最长路径问题,最长路径问题也是NP完全问题

2017-07-13 12:04:40 3772

原创 复习三-bfs

题目描述107. Binary Tree Level Order Traversal IIDescriptionHintsSubmissionsSolutionsTotal Accepted: 127134Total Submissions: 321893Difficulty: EasyContributo

2017-06-20 00:22:14 289

原创 复习二:dfs

临近期末,把之前做过的题目(有部分是未做过的)重新做一遍,整合到一起,为了省时间,就不贴代码了,只分析思路。DFS题目:104:树的最大深度。用depth表示深度,递归调用计算深度的函数,如果当前深度大于depth,更新depth。最后返回depth。递归的顺序是:先根,然后左子树,最后右子树。void dfs(TreeNode* p, int de) {

2017-06-11 18:27:00 246

原创 复习一:分治算法

临近期末,把之前做过的题目(有部分是未做过的)重新做一遍,整合到一起,为了省时间,就不贴代码了,只分析思路。分治算法题目:1、Search a 2D Matrix II:在一个每行每列都有序的矩阵中搜索某一数字。2、Kth Largest Element in an Array:找到数组里第k大元素。可以参考quick select算法,但是我偷懒使

2017-06-11 18:16:32 258

原创 动态规划——474. Ones and Zeroes[medium]

题目描述In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator of m 0s and n 1s respectively.

2017-06-04 11:33:01 229

原创 213. House Robber II[Medium]

题目大意Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention.

2017-06-04 11:17:59 254

原创 动态规划——72. Edit Distance[HARD]

题目描述Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted

2017-05-29 20:09:09 345

原创 动态规划——377. Combination Sum IV[Medium]

题目描述Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target =

2017-05-29 19:57:44 247

原创 动态规划——516. Longest Palindromic Subsequence[Medium]

题目描述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: 4One possible lo

2017-05-29 19:36:20 222

原创 动态规划——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,

2017-05-21 21:53:48 247

原创 动态规划——486. Predict the Winner[Medium]

题目描述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-21 21:38:29 269

原创 动态规划——343. Integer Break[Medium]

题目描述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-05-21 21:14:31 252

原创 动态规划——446. Arithmetic Slices II - Subsequence[HARD]

终于又做了一道 HARD,新学了hash_map……题目描述A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.Fo

2017-05-13 21:58:02 289

原创 动态规划——62. Unique Paths[medium]

题目描述A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to

2017-05-13 21:38:14 258

原创 动态规划——357. Count Numbers with Unique Digits[medium]

题目描述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 [11

2017-05-13 21:18:10 248

原创 动态规划——70. Climbing Stairs[easy]

题目描述You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will

2017-05-07 00:10:31 282

原创 动态规划——121. Best Time to Buy and Sell Stock[easy]

题目描述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 t

2017-05-06 20:06:32 177

原创 动态规划——198. House Robber[easy]

题目描述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

2017-05-06 19:48:04 298

原创 动态规划——303. Range Sum Query - Immutable[easy]

题目描述Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) ->

2017-05-06 19:31:55 271

原创 动态规划——413. Arithmetic Slices[Medium]

题目描述A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 A slice (P, Q) of array A is called arithmetic if the sequence:

2017-04-29 00:32:13 328

原创 动态规划——338. Counting Bits[Medium]

题目描述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:F

2017-04-29 00:09:04 433

原创 greedy——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 s

2017-04-23 23:07:38 165

原创 greedy——435. Non-overlapping Intervals[medium]

题目描述Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interval's end po

2017-04-16 11:55:22 311

原创 greedy——452. Minimum Number of Arrows to Burst Balloons[medium]

题目描述There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal,

2017-04-16 11:32:37 254

原创 dfs-329. Longest Increasing Path in a Matrix[Hard]

题目描述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 mo

2017-04-03 21:34:45 188

原创 bfs-407. Trapping Rain Water II[Hard]

题目描述Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Both

2017-04-03 00:29:19 234

原创 拓扑排序-207. Course Schedule[medium]

题目描述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 exp

2017-04-03 00:12:46 251

原创 dfs-104. Maximum Depth of Binary Tree

题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.对树左右递归,返回值较大的深度

2017-03-26 22:31:09 169

原创 图(dfs)494. Target Sum[middle]

题目:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.

2017-03-18 23:06:21 237

原创 图(深度优先搜索)491. Increasing Subsequences[Middle]03-18

题目: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 .Example:

2017-03-18 22:32:50 443

原创 图(广度优先搜索)515. Find Largest Value in Each Tree Row[Middle]

题目:You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]找到二叉

2017-03-18 21:38:45 303

原创 分治系列——315. Count of Smaller Numbers After Self[hard]

题目You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

2017-03-10 21:34:46 282

原创 分治系列——312. Burst Balloons[hard]03-09

题目描述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 wi

2017-03-09 19:55:17 236

原创 分治算法(三)215. Kth Largest Element in an Array【middle】03-04

1、题目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 = 2,

2017-03-04 10:59:00 211

原创 分治算法(二)240. Search a 2D Matrix II【middle】03-04

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.In

2017-03-04 10:43:01 254

原创 分治算法(一)241Different Ways to Add Parentheses【middle】03-02

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 *.Inp

2017-03-02 00:29:36 255

原创 495. Teemo Attacking【middle】&& 485. Max Consecutive Ones【easy】 02-24

这是林瀚老师布置的算法题,这是第一次,学号15336201,15网工,中山大学,02-24

2017-02-24 21:00:10 256

空空如也

空空如也

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

TA关注的人

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