自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法概论第八章课后习题8.8

题目:在精确的4SAT(EXACT4SAT)问题中,输入为一组子句,每个句子都是恰好为4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果赋值存在。证明精确的4SAT是NP-完全问题。证明:首先证明4SAT与3SAT等价,4SAT子句的形式(a1a{_1}, a2a_2 ,a3a_3 ,a4a_4),可以通过新增两个变量来将其拆分分成两个包含三个文字的子句:(a1a_1,

2017-07-06 13:42:38 439

原创 LeetCode 343. Integer Break

题目: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 n =

2017-07-04 17:23:13 247

原创 LeetCode 516. Longest Palindromic Subsequence

题目: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 longest

2017-07-04 16:00:42 326

原创 LeetCode 467. Unique Substrings in Wraparound String

题目:Consider the string s to be the infinite wraparound string of “abcdefghijklmnopqrstuvwxyz”, so s will look like this: “…zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd….”. Now we have ano

2017-06-19 10:04:01 307

原创 LeetCode 523. Continuous Subarray Sum

题目: Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up

2017-06-18 11:41:16 399

原创 LeetCode 264. Ugly Number II

题目:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example,1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the

2017-06-01 14:01:49 212

原创 LeetCode 376. Wiggle Subsequence

题目:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either

2017-05-31 22:03:48 172

原创 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 arithmetic sequ

2017-05-17 17:39:42 211

原创 LeetCode 368. Largest Divisible Subset

题目:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solutions

2017-05-17 15:58:43 235

原创 LeetCode 322. Coin Change

题目:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of m

2017-05-16 17:02:55 407

原创 LeetCode 486. Predict the Winner

题目:给出一个数组,玩家1和玩家2轮流从数组的两端无放回地抽取一个数字(玩家1先抽),当数组被抽完时计算两个玩家的数字总和,总和数值大者为胜者。现在给出一个数组,预测玩家1能否胜出。例子:Input: [1, 5, 2]Output: FalseExplanation: Initially, player 1 can choose between 1 and 2. If he

2017-05-02 20:03:19 219

原创 LeetCode 392. Is Subsequence

题目:Given a string s and a string t, check ifs is subsequence of t. You may assume that there is only lower case English letters in both s andt. t is potentially a very long (length ~= 500,000) s

2017-05-01 23:22:35 222

原创 LeetCode 416. Partition Equal Subset Sum

题目:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.题目:给出一个非空正整数数组,问是否能将该数组拆分

2017-05-01 17:29:37 240

原创 LeetCode 410. Split Array Largest Sum

题目:给出一个由非负整数组成的数组和整数m,把该数组切分成m个非空连续子数组,并最小化m个子数组总值最大值。注意:1 ≤ n ≤ 1000,1 ≤ m ≤ min(50,n) 其中n为数组长度。例子:输入:nums = [7,2,5,10,8]           m = 2输出:18解题思路:显然,无论怎么切分数组,各子数组的总值中的最大值不小于数组中最大的元素。那么

2017-04-16 20:41:45 304

原创 Leetcode 474. Ones and Zeroes

题目: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. On the othe

2017-04-06 19:36:17 332

原创 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 the t

2017-03-26 16:59:28 219

原创 Leetcode 111. Minimum Depth of Binary Tree

题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.即求根结点到其叶节点的最短距离。简单地用BFS就可以解决问

2017-03-21 15:02:37 249

原创 Leetcode 494. Target Sum Add to List

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

2017-03-09 20:02:42 488

原创 Leetcode 241. Different Ways to Add Parentheses

题目: 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 *.例子1:

2017-03-04 17:24:16 526 1

原创 Leetcode:1. Two Sum

题目:1.Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may n

2017-02-26 21:55:14 323

空空如也

空空如也

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

TA关注的人

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