- 博客(21)
- 问答 (1)
- 收藏
- 关注
原创 期末作业NP问题
8.3题首先,易知STINGY SAT 的解是可在多项式时间内验证的,因此属于NP。另外,很容易可以将SAT 归纳到STINGY SAT(将k 设为所有变量的总个数即可),所以可知STINGY SAT 为NP 完全问题。8.8题首先很显然,EXACT 4SAT 属于NP。现在通过将3SAT 归纳到EXACT 4SAT 来证明后者的NP 完全性。对于任意一个3SAT 实例,如
2017-07-13 22:33:02 405
原创 【LeetCode】101. Symmetric Tree
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4
2017-06-16 15:31:39 212
原创 【LeetCode】199. Binary Tree Right Side View
题目:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree
2017-06-08 20:52:23 204
原创 【LeetCode】62. Unique Paths
题目: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 r
2017-05-30 23:33:46 269
原创 【LeetCode】129. Sum Root to Leaf Numbers
题目:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find
2017-05-25 21:30:50 163
原创 【LeetCode】435. Non-overlapping Intervals
题目: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 poi
2017-05-19 15:47:09 270
原创 【LeetCode】452. Minimum Number of Arrows to Burst Balloons
题目: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-05-11 20:53:45 214
原创 【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 si
2017-05-03 23:24:07 168
原创 【LeetCode】413. Arithmetic Slices
题目:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmeti
2017-04-29 10:28:01 166
原创 【LeetCode】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,0
2017-04-20 23:29:44 262
原创 【LeetCode】312. Burst Balloons
题目: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-15 23:56:32 178
原创 【LeetCode】312. Burst Balloons
题目: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 w
2017-04-07 20:45:23 263
原创 【LeetCode】547. Friend Circles
题目:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend
2017-04-03 11:21:47 2112
原创 【LeetCode】100. Same Tree
题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2017-03-26 11:45:10 409
原创 【LeetCode】496. Next Greater Element I
题目:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding place
2017-03-17 23:18:15 175
原创 【LeetCode】169. Majority Element
题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority
2017-03-09 23:32:12 191
原创 【LeetCode】349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.T
2017-03-09 22:30:49 177
原创 【LeetCode】414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2,
2017-03-02 21:47:45 219
原创 【LeetCode】442. Find All Duplicates in an Array
题目:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it w
2017-03-02 19:09:16 179
原创 【LeetCode】448. Find All Numbers Disappeared in an Array
题目:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this a
2017-02-25 16:32:48 301
原创 【LeetCode】485. Max Consecutive Ones
题目:Given a binary array, find the maximum number of consecutive 1s in this array.Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s.
2017-02-24 22:19:52 338
空空如也
Chrome浏览器黑屏,右下角显示扩展程序崩溃,什么网页都打不开
2017-12-18
TA创建的收藏夹 TA关注的收藏夹
TA关注的人