![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法设计
guo_x_l
这个作者很懒,什么都没留下…
展开
-
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 · 181 阅读 · 0 评论 -
算法概论 习题8.16
题目: EXPERIMENTAL CUISINE Input: n, the number of ingredients to choose from: D,the n*n "discord" matrix; some number p >= 0 Output: The maximum number of ingredients we can choose with penalty Sh原创 2017-07-11 23:47:17 · 251 阅读 · 0 评论 -
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) -> 1 sumRange(2, 5) -> -1原创 2017-06-19 20:40:23 · 271 阅读 · 0 评论 -
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 · 215 阅读 · 0 评论 -
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 · 161 阅读 · 0 评论 -
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 · 188 阅读 · 0 评论 -
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 · 230 阅读 · 0 评论 -
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 · 155 阅读 · 0 评论 -
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 · 153 阅读 · 0 评论 -
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 · 148 阅读 · 0 评论 -
133. Clone Graph
题目: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator fo原创 2017-04-05 21:12:48 · 284 阅读 · 0 评论 -
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 · 159 阅读 · 0 评论 -
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 · 186 阅读 · 0 评论 -
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 · 155 阅读 · 0 评论 -
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 · 217 阅读 · 0 评论 -
485. Max Consecutive Ones
这道题主要就是对输入的二进制数组进行判断并输出数组中连续为1的最大长度。 题解比较容易,按顺序遍历整个数组,只要对每次数组元素为1就进行计数,当遇到0时,停止计数;当重新遇到1时,就用一个新的变量计数,遇到0时同样停止,然后将前后两次次数变量进行比较,保留较大数;以此类推…… 解题的代码如下: class Solution { public: int findMaxConsecuti原创 2017-02-26 11:54:25 · 164 阅读 · 0 评论 -
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 · 175 阅读 · 0 评论