- 博客(17)
- 资源 (2)
- 收藏
- 关注
原创 算法概论 习题8.16
题目:EXPERIMENTAL CUISINEInput: n, the number of ingredients to choose from: D,the n*n "discord" matrix; some number p >= 0Output: The maximum number of ingredients we can choose with penalty Sh
2017-07-11 23:47:17
270
原创 303. Range Sum Query - Immutable
题目:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1
2017-06-19 20:40:23
289
原创 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 0 ≤ x [11,
2017-06-12 16:17:38
201
原创 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 symbol.
2017-06-05 19:26:21
238
原创 96. Unique Binary Search Trees
题目:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2
2017-05-18 19:34:35
180
原创 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 = 2
2017-05-11 19:54:02
179
原创 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 time a playe
2017-05-08 20:22:10
208
原创 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,
2017-05-02 21:22:56
180
原创 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-04-24 20:27:46
251
原创 55. 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 position.Determ
2017-04-16 23:51:48
171
原创 133. Clone Graph
题目:Clone an undirected graph. Each node in the graph contains a label and a list of itsneighbors. OJ's undirected graph serialization:Nodes are labeled uniquely. We use # as a separator fo
2017-04-05 21:12:48
304
原创 399. Evaluate Division
题目:Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If
2017-03-30 19:40:35
184
原创 207. Course Schedule
题目: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 expr
2017-03-21 20:50:28
211
原创 53. 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 subarray [4,-
2017-03-18 20:27:55
240
原创 240. 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 to right.Integ
2017-03-08 19:22:44
202
原创 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 elemen
2017-03-05 23:10:02
174
原创 485. Max Consecutive Ones
这道题主要就是对输入的二进制数组进行判断并输出数组中连续为1的最大长度。题解比较容易,按顺序遍历整个数组,只要对每次数组元素为1就进行计数,当遇到0时,停止计数;当重新遇到1时,就用一个新的变量计数,遇到0时同样停止,然后将前后两次次数变量进行比较,保留较大数;以此类推……解题的代码如下:class Solution {public: int findMaxConsecuti
2017-02-26 11:54:25
189
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人