- 博客(21)
- 资源 (1)
- 收藏
- 关注
原创 吝啬SAT是NP-完全问题
《算法概论》8.3吝啬SAT问题是这样的:给定一组子句 (每个子句都是其中文字的析取) 和整数 k,求一个最多有 k 个变量为 true 的满足赋值——如果该赋值存在。证明吝啬SAT是NP-完全问题。证明:已知SAT问题是NPC问题。要证明吝啬SAT问题是NPC问题,只须证明,一个SAT问题可以在多项式时间归约到吝啬SAT问题。假设SAT问题有n个变量,令吝啬SAT问题中的k为SAT问题中的n,即在
2017-07-14 13:12:50
476
原创 (LeetCode) 204. Count Primes
204. Count PrimesDescription:Count the number of prime numbers less than a non-negative number, n.代码int countPrimes(int n) { if (n<=2) return 0; vector<bool> passed(n, false); int sum = 1;
2017-05-30 22:01:13
179
原创 (LeetCode) 491. Increasing Subsequences
491. Increasing SubsequencesGiven 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
2017-05-30 21:54:31
259
原创 (LeetCode) 215. Kth Largest Element in an Array
215. Kth Largest Element in an ArrayFind 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
2017-05-30 21:51:50
184
原创 (LeetCode) 421. Maximum XOR of Two Numbers in an Array
421. Maximum XOR of Two Numbers in an ArrayGiven a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.Could you do this in O(n
2017-05-30 21:46:53
205
原创 (LeetCode) 343. Integer Break
343. Integer BreakGiven 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, giv
2017-05-30 21:34:04
195
原创 (LeetCode) 338. Counting Bits
338. Counting BitsGiven 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:
2017-05-30 21:26:55
187
原创 (LeetCode) 62. Unique Paths
62. Unique PathsA 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-30 21:24:29
173
原创 (LeetCode) 494. Target Sum
494. Target SumYou 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.Find
2017-05-30 21:21:29
249
原创 (LeetCode) 328. Odd Even Linked List
328. Odd Even Linked ListGiven 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 sh
2017-05-30 21:16:56
165
原创 (LeetCode) 46. Permutations
46. PermutationsGiven a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1],`这里写代码片` [3
2017-05-30 21:11:25
180
原创 (LeetCode) 199. Binary Tree Right Side View
199. Binary Tree Right Side ViewGiven 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 fol
2017-05-30 21:06:09
204
原创 (LeetCode) 279. Perfect Squares
279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4
2017-05-30 20:57:44
145
原创 (LeetCode) 543. Diameter of Binary Tree
543. Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a t
2017-04-12 12:27:45
263
原创 (LeetCode) 108. Convert Sorted Array to Binary Search Tree
108. Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.思路将升序排序的数组变成一个平衡二叉搜索树,只需要在中间切断,将数组分为左右子树,继续递归下去。代码class S
2017-04-12 12:24:46
231
原创 (LeetCode) 114. Flatten Binary Tree to Linked List
114. Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:
2017-04-11 18:36:43
171
原创 (LeetCode) 129. Sum Root to Leaf Numbers
129. Sum Root to Leaf NumbersGiven 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
2017-04-11 18:03:23
200
autoML-survey.pdf
2020-04-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人