- 博客(35)
- 资源 (1)
- 收藏
- 关注
原创 算法概论课本题目Chapter 8 Exercises 8.10
8.10. Proving NP-completeness by generalization. For each of the problems below, prove that it is NP-complete by showing that it is a generalization of some NP-complete problem we have seen in this ch
2017-06-19 16:08:41
396
原创 LeetCode题目:Roman to Integer
题目地址:点击打开链接 题目描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999 代码:class Solution { public: int romanToInt(string s) { unorde
2017-06-17 19:43:28
189
原创 LeetCode题目:Integer to Roman
题目原址:点击打开链接 题目描述: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. Subscribe to see which companies asked this question. 代码:cla
2017-06-17 19:26:31
206
原创 LeetCod题目:Container With Most Water
题目地址:点击打开链接 题目描述: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i,
2017-06-17 19:15:26
197
原创 LeetCode题目:Palindrome Number
题目地址:点击打开链接 题目描述: Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi
2017-06-10 20:11:17
194
原创 LeetCode题目:String to Integer (atoi)
题目原址:点击打开链接 题目描述: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are t
2017-06-10 19:36:00
191
原创 LeetCode题目7. Reverse Integer
题目原址:点击打开链接 题目描述: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good question
2017-06-03 18:06:35
165
原创 LeetCode题目:494. Target Sum
题目地址:点击打开链接 题目描述: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 s
2017-06-03 16:19:02
261
原创 LeetCode题目:486. Predict the Winner
题目原址:点击打开链接 题目描述: 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
2017-05-28 12:00:28
281
原创 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 exa
2017-05-20 20:22:10
191
原创 LeetCode题目:357. Count Numbers with Unique Digits
题目原址:点击打开链接 题目描述: 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
2017-05-20 19:52:15
182
原创 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 ar
2017-05-13 20:56:01
168
原创 LeetCode 题目:91. Decode Ways
题目地址:点击打开链接 题目描述: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits,
2017-05-06 18:59:22
357
原创 LeetCode题目:338. Counting Bits
题目原址:点击打开链接 题目描述: 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.
2017-05-06 18:43:33
230
原创 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 exis
2017-04-29 15:19:38
179
原创 LeetCode 题目:435. Non-overlapping Intervals Add to List
题目原址:点击打开链接 题目描述: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 interv
2017-04-29 14:22:36
246
原创 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 (le
2017-04-23 15:57:19
181
原创 LeetCode题目:452. Minimum Number of Arrows to Burst Balloons Add to List
题目原址:点击打开链接 题目描述: 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 i
2017-04-23 15:14:15
229
原创 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
2017-04-16 20:54:47
173
原创 LeetCode题目:122. Best Time to Buy and Sell Stock II
题目原址:点击打开链接 题目描述: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions
2017-04-16 20:34:35
186
原创 LeetCode题目:315. Count of Smaller Numbers After Self
题目地址:点击打开链接 题目描述: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 o
2017-04-08 15:32:59
230
原创 LeetCode题目:6. ZigZag Conversion Add to List
题目原址:点击打开链接 题目描述:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H
2017-04-08 14:20:26
320
原创 LeetCode题目 5. Longest Palindromic Substring
题目地址:点击打开链接 题目描述: 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 al
2017-04-02 16:05:32
219
原创 LeetCode 题目 4. Median of Two Sorted Arrays
题目原址 :点击打开链接 题目描述: 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)).
2017-04-02 11:56:21
346
原创 LeetCode 题目 3. Longest Substring Without Repeating Characters Add to List
题目地址 点击打开链接 题目描述: 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 "bbbb
2017-03-26 15:53:11
326
1
原创 LeetCode 作业题目:2. Add Two Numbers
题目原址:点击打开链接 题目描述: 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
2017-03-26 14:36:14
279
原创 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 balloo
2017-03-18 20:59:27
242
原创 LeeCode题目:169. Majority Element Add to List
题目地址:点击打开链接 题目描述: 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
2017-03-18 19:01:32
339
原创 LetetCode题目Search a 2D Matrix II
题目地址:点击打开链接 题目描述: 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
2017-03-12 11:59:40
334
原创 LeetCode题目Kth Largest Element in an Array
题目原址:点击打开链接 题目描述: 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] a
2017-03-11 21:45:27
291
原创 LeetCode作业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 a
2017-03-04 17:45:10
236
原创 LeetCode作业:Maximum Subarray
题目原址:点击打开链接 题目描述: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous s
2017-03-04 17:27:16
226
原创 算法设计与应用基础作业(三)
题目地址:点击打开链接 题目描述: In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe
2017-02-26 00:02:43
264
原创 算法设计与应用基础作业(二)
题目地址:点击打开链接 题目描述: Given 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
2017-02-25 17:45:11
220
原创 算法设计与应用基础作业(一)
题目网址:点击打开链接 题目描述:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three dig
2017-02-25 17:20:19
280
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅