自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 SpringMVC拦截器

一、定义Interceptor实现类   SpringMVC 中的Interceptor 拦截请求是通过HandlerInterceptor 来实现的。在SpringMVC 中定义一个Interceptor 非常简单,主要有两种方式,第一种方式是要定义的Interceptor类要实现了Spring 的HandlerInterceptor 接口,或者是这个类继承实现了HandlerInterce

2017-07-20 14:24:03 128

原创 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 225

原创 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 147

原创 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 143

原创 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 150

原创 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 180

原创 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 156

原创 Java优先级队列

PriorityQueue是个基于优先级堆的极大优先级队列。此队列按照在构造时所指定的顺序对元素排序,既可以根据元素的自然顺序来指定排序(参阅 Comparable),也可以根据 Comparator 来指定,这取决于使用哪种构造方法。优先级队列不允许 null 元素。依靠自然排序的优先级队列还不允许插入不可比较的对象(这样做可能导致 ClassCastException)

2017-04-05 21:24:23 370

原创 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 143

原创 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 155

原创 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 138

原创 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 144

原创 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 215

原创 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 135

原创 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 244

原创 Largest Rectangle in Histogram

84. Largest Rectangle in HistogramAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 84767Total Submissions: 325790Difficulty: HardContributor: LeetCode

2017-03-30 17:46:30 236

原创 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 144

原创 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 155

原创 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 135

原创 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 170

原创 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 141

原创 Next Greater Element I

496. Next Greater Element IAdd to ListDescriptionSubmissionsSolutionsTotal Accepted: 14978Total Submissions: 26028Difficulty: EasyContributors: µsic_forever

2017-03-27 16:32:42 228

原创 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 308

原创 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 204

原创 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 135

原创 Vaild PerfectSquare (注意数据溢出)

2017-03-21 10:29:15 164

原创 Split Array Largest Sum

2017-03-14 22:19:37 162

原创 整数中1出现的次数

2017-03-12 22:27:42 104

原创 旋转数组的最小数字

2017-03-11 20:39:38 99

原创 调整数组顺序使奇数位于偶数前面

2017-03-11 17:13:09 126

原创 JAVA持有对象

2017-03-09 12:07:50 187

原创 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 126

原创 Leetcode-Unique Substrings in Wraparound String

Leetcode

2017-03-03 21:59:04 171

空空如也

空空如也

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

TA关注的人

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