![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
Vent_NCS
菜鸟也要高飞
展开
-
初次小试
Try first题目Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Note: The input is assumed to be a 32-bit signed integer. Your functi原创 2017-02-25 12:51:21 · 318 阅读 · 0 评论 -
Word Break
题目Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a spaceseparated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["原创 2017-08-02 10:25:35 · 211 阅读 · 0 评论 -
World Break II
题目Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "catsan原创 2017-08-02 10:32:59 · 845 阅读 · 0 评论 -
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. Integers in each c原创 2017-06-14 20:22:11 · 242 阅读 · 0 评论 -
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] and k = 2, return 5.Note原创 2017-06-13 21:00:49 · 199 阅读 · 0 评论 -
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 element alway原创 2017-06-13 20:10:17 · 225 阅读 · 0 评论 -
House Robber
House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adj原创 2017-06-10 16:55:30 · 234 阅读 · 0 评论 -
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 sumRange(0, 5)原创 2017-06-10 16:08:31 · 258 阅读 · 0 评论 -
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 as you like (ie, buy one a原创 2017-06-15 21:01:37 · 216 阅读 · 0 评论 -
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 size of a co原创 2017-06-15 20:47:25 · 275 阅读 · 0 评论 -
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, return原创 2017-05-31 20:07:46 · 227 阅读 · 0 评论 -
Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7],原创 2017-05-25 19:47:35 · 216 阅读 · 0 评论 -
Maximum Subarray
Maximum Subarray做这个题之后,发现自己真的很LOW。。。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 con原创 2017-04-15 20:44:33 · 338 阅读 · 0 评论 -
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 *.Example 1 Input原创 2017-03-05 18:24:39 · 235 阅读 · 0 评论 -
Add Binary
题目Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".分析对于给定的两个二进制数字所表达的字符串,我们求其相加所得到的结果, 根据上例便可 得到答案. 要注意1. 对字符串的操作. 2. 对于加法,我们应该建立一个进位单位,保存原创 2017-08-18 22:00:01 · 282 阅读 · 0 评论