- 博客(30)
- 收藏
- 关注
原创 8.10
(a)子图同构问题: 设算法f:能在多项式时间内把图G映射为一个圈。 则算法f可以把本问题的输入映射为Hamilton圈问题的输入,即对于H的所有子图,是否有一个子图存在Hamilton圈。 综上,本问题可以归约为Hamilton圈问题(书上的Rudrata问题)。 (b)最长路径问题: 设算法f:能在多项式时间内找出G的一个含有V个顶点的子图H,且g=V-1。
2017-07-10 10:21:52 293
原创 516. Longest Palindromic Subsequence (Medium)
题目大意如下: Longest Palindromic Subsequence: 给定一个整数序列,找出最长回文子序列。 Longest Palindromic Substring : 给定一个整数序列,找出最长回文子串。 注:子串为连续的,子序列不一定是连续的。解题思路: Longest Palindromic Subsequence: 用
2017-06-10 22:17:10 272
原创 300. Longest Increasing Subsequence (Medium)
原题目: Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18]. The longest increasing subsequence is [2, 3, 7, 10
2017-06-10 15:24:56 236
原创 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 adjacen
2017-06-05 23:06:59 237
原创 598. Range Addition II (Easy)
原题目: Given an m * n matrix M initialized with all 0’s and several update operations. Operations are represented by a 2D array, and each operation is represented by an array with two positive intege
2017-05-29 23:08:44 195
原创 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 be a p
2017-05-22 20:33:57 196
原创 582. Kill Process(Medium)
原题目: Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This is j
2017-05-14 11:49:20 345
原创 572. Subtree of Another Tree(Easy)
原题目: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of th
2017-05-08 20:32:29 1279
原创 573. Squirrel Simulation(Medium)
原题目: There’s a tree, a squirrel, and several nuts. Positions are represented by the cells in a 2D grid. Your goal is to find the minimal distance for the squirrel to collect all the nuts and put the
2017-05-08 20:15:25 339
原创 576. Out of Boundary Paths(Hard)
原题目: 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).
2017-05-08 15:48:04 361
原创 564. Find the Closest Palindrome (Hard)
原题目: Given an integer n, find the closest integer (not including itself), which is a palindrome. The ‘closest’ is defined as absolute difference minimized between two integers.Example 1:Input: "
2017-04-25 19:56:03 1906
原创 55. Jump Game(Medium)&& 45. Jump Game II(Hard)
原题目: 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 at that posi
2017-04-25 10:51:29 229
原创 406. Queue Reconstruction by Height (Medium)
原题目: Suppose 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 k is the number of people in front o
2017-04-23 13:07:52 910
原创 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, y-
2017-04-23 12:50:20 385
原创 330. Patching Array(Hard)
原题目: Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the arra
2017-04-22 10:46:58 226
原创 553. Optimal Division(Medium)
原题目: Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4. However, you can add any number of parenthesis at any position to c
2017-04-16 13:00:43 1522
原创 207. Course Schedule (Medium)&& 210. Course Schedule II(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 expressed
2017-04-15 19:46:21 261
原创 301. Remove Invalid Parentheses (Hard)
原题目: Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( an
2017-04-11 19:36:34 1982
原创 513. Find Bottom Left Tree Value (Medium)
原题目: Given a binary tree, find the leftmost value in the last row of the tree. Example 1:Input: 2 / \ 1 3Output: 1Example 2:Input: 1 / \ 2 3 / / \4 5 6 / 7Output:
2017-04-09 11:46:44 271
原创 515. Find Largest Value in Each Tree Row(Medium)
原题目: 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-04-09 11:17:07 244
原创 542. 01 Matrix(Medium)
原题目: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Note:1.The number of elements of the given matrix will no
2017-04-02 23:21:57 204
原创 529. Minesweeper(Medium)
原题目: You are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine, ‘E’ represents an unrevealed empty square, ‘B’ represents a revealed blank square that has no adja
2017-03-21 12:00:31 369
原创 514. Freedom Trail (Hard)
原题目: In the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial called the “Freedom Trail Ring”, and use the dial to spell a specific keyword in order to open the
2017-03-14 23:56:58 410
原创 312. Burst Balloons (Hard)
原题目: 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 will get
2017-03-03 17:13:35 285
原创 5. Longest Palindromic Substring (Medium)
原题目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Input: “babad” Output: “bab” Note: “aba” is also a valid
2017-03-01 16:06:08 213
原创 4. Median of Two Sorted Arrays (Hard)
原题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: n
2017-02-25 12:04:07 283
原创 3. Longest Substring Without Repeating Characters (Medium)
原题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer
2017-02-25 11:18:16 280
原创 2. Add Two Numbers(Medium)
原题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and r
2017-02-22 17:35:07 259
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人