- 博客(33)
- 收藏
- 关注
原创 SpringMVC拦截器
一、定义Interceptor实现类 SpringMVC 中的Interceptor 拦截请求是通过HandlerInterceptor 来实现的。在SpringMVC 中定义一个Interceptor 非常简单,主要有两种方式,第一种方式是要定义的Interceptor类要实现了Spring 的HandlerInterceptor 接口,或者是这个类继承实现了HandlerInterce
2017-07-20 14:24:03
152
原创 leetcode-Remove Boxes
/** 采用记忆搜索* dp[left][right][k]:boxes编号从left到right,且左边有k个boxe跟boxes[left]相同* 思路:左边的k个可以先跟boxes[left]移除,也可以保留下来跟右边的bxoes[left]相同的移除* dp[left][right][k]=Max{(k+1)^2+dp[left+1][right][0],max(dp[le
2017-06-12 08:55:39
273
原创 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2017-04-07 22:35:28
178
原创 Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant
2017-04-07 22:08:04
167
原创 Delete Node in a BST
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divided i
2017-04-07 16:50:52
190
原创 493. Reverse Pairs
Given an array nums, we call (i, j) an important reverse pair if i and nums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.Example1:Input: [1
2017-04-06 11:26:14
219
原创 The Skyline Problem
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as
2017-04-05 21:50:42
190
原创 Java优先级队列
PriorityQueue是个基于优先级堆的极大优先级队列。此队列按照在构造时所指定的顺序对元素排序,既可以根据元素的自然顺序来指定排序(参阅 Comparable),也可以根据 Comparator 来指定,这取决于使用哪种构造方法。优先级队列不允许 null 元素。依靠自然排序的优先级队列还不允许插入不可比较的对象(这样做可能导致 ClassCastException)
2017-04-05 21:24:23
429
原创 Range Sum Query - Mutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Examp
2017-04-05 20:15:55
166
原创 Trapping Rain Water II
Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Both m and n are l
2017-04-04 20:47:04
186
原创 310. Minimum Height Trees
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini
2017-04-04 16:19:12
162
原创 Number of Islands
DescriptionSubmissionsSolutionsTotal Accepted: 96206Total Submissions: 288576Difficulty: MediumContributor: LeetCodeGiven a 2d grid map of '1's (land) and '0's (water), c
2017-04-03 18:23:43
166
原创 01 Matrix
DescriptionSubmissionsSolutionsTotal Accepted: 3068Total Submissions: 9208Difficulty: MediumContributors:Stomach_acheGiven a matrix consists of 0 and 1, find the distan
2017-04-03 17:55:21
246
原创 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 of nums[i].Example
2017-04-01 15:53:12
157
原创 Concatenated Words
Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words.A concatenated word is defined as a string that is comprised entir
2017-03-31 16:31:07
287
原创 Largest Rectangle in Histogram
84. Largest Rectangle in HistogramAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 84767Total Submissions: 325790Difficulty: HardContributor: LeetCode
2017-03-30 17:46:30
285
原创 Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1
2017-03-30 17:12:48
174
原创 Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order a
2017-03-29 23:00:47
181
原创 Pattern leetcode
Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i j k and ai < ak j. Design an algorithm that takes a list of n numbers as input and check
2017-03-29 17:26:42
164
原创 Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will b
2017-03-29 17:19:53
212
原创 Trapping Rain Water-Leetcode
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]
2017-03-29 17:11:12
175
原创 Next Greater Element I
496. Next Greater Element IAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 14978Total Submissions: 26028Difficulty: EasyContributors: µsic_forever
2017-03-27 16:32:42
241
原创 Kth Smallest Element in a Sorted Matrix (Leetcode)二分法
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not
2017-03-22 21:17:14
343
原创 Find the Duplicate Number (Leetcode)
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
2017-03-22 20:13:31
238
原创 Find the Duplicate Number
二分法复杂度时间 O(NlogN) 空间 O(1)思路实际上,我们可以根据抽屉原理简化刚才的暴力法。我们不一定要依次选择数,然后看是否有这个数的重复数,我们可以用二分法先选取n/2,按照抽屉原理,整个数组中如果小于等于n/2的数的数量大于n/2,说明1到n/2这个区间是肯定有重复数字的。比如6个抽屉,如果有7个袜子要放到抽屉里,那肯定有一个抽屉至少两个袜子。这里抽屉
2017-03-22 20:05:14
151
原创 Largest Divisible Subset
public static List largestDivisibleSubset(int[] nums) {List res=new LinkedList();if(nums.length==0)return res; int[] dp=new int[nums.length]; int[] pre=new int[nums.length];
2017-03-04 17:12:36
145
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人