自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode---(84)Largest Rectangle in Histogram

Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o

2015-06-23 23:22:45 207

原创 LeetCode---(150)Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "

2015-06-23 22:49:10 206

原创 LeetCode---(42)Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]

2015-06-23 22:06:14 211

原创 LeetCode---(32)Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",

2015-06-23 16:55:11 211

原创 LeetCode---(20)Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-06-23 15:35:04 250

转载 LeetCode---(152)Maximum Product Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest

2015-06-21 20:01:37 237

原创 LeetCode---(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,−1,2,1] ha

2015-06-21 10:50:55 264

转载 LeetCode---(137)Single Number II

Given an array of integers, every element appears three times except for one. Find that single one.之前做过了数组中其他数出现两次,仅有一个出现一次的,直接用所有元素异或就行了(只要是偶数次,都可以用这个方法),本题变为其他元素出现3次,而且时间复杂度要求线性,空间为常数。解法为:

2015-06-19 22:15:14 203

转载 LeetCode---(164)Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements

2015-06-19 20:31:53 175

转载 Leetcode---(104)Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.首先考虑递归/** * Definition for a bina

2015-06-17 22:03:51 162

原创 LeetCode---(100)Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.首先考虑递归的方法:

2015-06-17 21:34:54 199

转载 LeetCode---(119)Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].方法一:由于之前我们曾经遇到过建立Pascal三角形,所以我们自然联想到建立一个K+1的三角形,然后取出来第K行,就得到所求的结果。class Soluti

2015-06-16 22:41:23 165

转载 LeetCode---(202)Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares

2015-06-16 22:04:48 324

转载 LeetCode---(118)Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]将该三角形的左边对齐,就能够发现,tri[i][j] =

2015-06-15 22:54:02 210

转载 LeetCode---(13)Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字有如下符号:基本字符IVXLCDM对应阿拉伯数字15105010

2015-06-15 20:03:54 204

转载 Leetcode---(38)Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as

2015-06-15 19:02:07 149

转载 LeetCode---(7)Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c

2015-06-13 16:36:28 190

转载 LeetCode---(21)Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * struct

2015-06-06 22:53:48 186

原创 LeetCode---(88)Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold addit

2015-06-05 22:13:55 204

空空如也

空空如也

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

TA关注的人

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