自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 springboot maven多模块构建最简化配置

一直在本地运行的多模块项目需要放到服务器上,于是开始打包;以前没有接触过多模块的项目,碰到了一些坑,下面给正确的配置发出来:整个项目分为三个模块:common,core,web;core依赖common,web依赖common和core;在common和core(被依赖的module)的pom.xml中添加如下配置:<build> <plugins> ...

2018-03-01 20:30:48 2732

原创 二分查找总结

今天搜狐笔试,有一道算法题:给定排好序的成绩数组和及格分数线,要求找出及格的人数。看到这个题就知道有坑,及格分数线的分数不一定出现在数组之中,而且分数还有可能有重复的,最普通的二分查找法根本没办法处理这种情况,最后这题打得不怎么样。镇定思痛,看到一个还不错的总结:http://www.cnblogs.com/ider/archive/2012/04/01/binary_search.htm

2016-09-07 21:51:34 431

原创 LeetCode_OJ【337】 House Robber III

The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour

2016-09-02 10:25:35 336

原创 Java反射用法详解

在过去的几次面试中,都被问到了反射这块的知识,并没有系统了解过Java的反射机制(现实是几乎怎么接触过),所以这方面的问题基本都回答不上来T_T镇定思痛,我们来一起好好看看Java中反射的用法。

2016-08-26 21:27:37 7561 1

原创 ThreadLocal与WeakReference 源码分析

上篇了解通过源码,使用场景等等了解下ThreadLocal(地址:http://blog.csdn.net/hb_peng/article/details/52188960)其中讲到ThreadLocalMap继承了软应用类,但是为什么这么做,原理是什么却并没有讲。 首先了解下WeakReference,在 http://www.jianshu.com/p/c0ca0db80299 里

2016-08-12 10:53:26 1524

转载 Java并发编程:深入剖析ThreadLocal

想必很多朋友对ThreadLocal并不陌生,今天我们就来一起探讨下ThreadLocal的使用方法和实现原理。首先,本文先谈一下对ThreadLocal的理解,然后根据ThreadLocal类的源码分析了其实现原理和使用需要注意的地方,最后给出了两个应用场景。  以下是本文目录大纲:  一.对ThreadLocal的理解  二.深入解析ThreadLocal类  三.Thread

2016-08-12 10:17:58 356

原创 LeetCode_OJ【85】 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 0

2016-08-10 17:25:03 365

原创 LeetCode_OJ【78】Subsets

Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,

2016-04-27 16:21:17 491 1

原创 LeetCode_OJ【76】Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".

2016-04-26 12:00:50 300

原创 LeetCode_OJ【73】Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(mn) s

2016-04-22 15:39:29 322

原创 LeetCode_OJ【72】Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convertword1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2016-04-21 20:51:56 287

原创 LeetCode_OJ【71】Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"这道题一开始没想好,直接进行处理,结果写出的代码又臭又长,而且是用了提交大法,错了N多次才成功的。以下为第一次AC时

2016-04-20 15:36:26 259

原创 LeetCode_OJ【69】Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.这道题目没看到二分查找的提示的时候感觉还是比较难的,虽然用自己的方法能做出来,但是性能太差了。在不管使用什么方法时都要注意不要出现比x大的int型变量,否则极易溢出。n^2 > x 这种表达式最好都改写为 n > x /2.java实现如下:pub

2016-04-19 16:22:33 310

原创 LeetCode_OJ【68】Text Justification

Given an array of words and a length L, format the text such that each line has exactlyL characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is

2016-04-19 11:59:01 427

原创 Java Web中乱码问题的总结

最近一直在迁移实验室的网站,这些网站都是以前师兄编写的,年代有点久远,运行于jdk4 + tomcat4,由于一些原因现在必须要迁移到jdk7+tomcat7的环境中,迁移过程中最让我头疼的就是各种花式乱码。        乱码大都是前台传到后台时出现乱码,师兄的程序中也对这个部分做了一些处理:后台取到的值先按照ISO-8599-1格式转换,然后转为GBK格式(前台传入的格式就是GBK);

2016-04-11 16:57:38 425

转载 Hibernate防止SQL注入攻击的方法

如果在查询字段中输入单引号"'",则会报错,这是因为输入的单引号和其他的sql组合在一起编程了一个新的sql,实际上这就是SQL注入漏洞,后来我在前台和后台都对输入的字符进行了判断。 永远也不要写这样的代码:     String queryString = "from Item i where i.description like '" + searchString + "'";

2016-02-28 09:43:05 2739

原创 LeetCode_OJ【63】Unique Paths II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.

2016-02-22 17:11:43 309

原创 LeetCode_OJ【60】Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""

2016-02-20 11:06:38 330

原创 LeetCode_OJ【56】Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].这道题最好在57题做完了之后再做,leetcode上的这个顺序正好反过来了。一开始直接上手这个题目的思路

2016-02-19 19:53:22 271

原创 LeetCode_OJ【57】Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Examp

2016-02-19 15:03:45 308

原创 LeetCode_OJ【54】Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You

2016-02-18 09:35:44 276

原创 LeetCode_OJ【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] has

2016-02-17 15:22:30 271

原创 LeetCode_OJ【47】Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].

2016-01-28 17:18:22 320

原创 LeetCode_OJ【46】Permutations

Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1],[3,1,2], and [3,2,1].Subscri

2016-01-28 17:10:00 419

原创 LeetCode_OJ【48】Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Subscribe to see which companies asked this question

2016-01-19 18:53:53 337

原创 LeetCode_OJ【44】Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover

2016-01-14 17:34:41 348

原创 LeetCode_OJ【43】Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.Subscribe to see which companies asked

2016-01-13 11:51:44 233

原创 LeetCode_OJ【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]

2016-01-13 09:44:38 345

原创 LeetCode_OJ【40】Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inC where the candidate numbers sums to T.Each number in C may only be used once in the combinatio

2016-01-12 20:51:39 383

原创 LeetCode_OJ【39】Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations inC where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numbe

2016-01-12 20:48:19 282

原创 LeetCode_OJ【33】Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its

2015-10-19 16:23:15 210

原创 LeetCode_OJ【30】Substring with Concatenation of All Words

You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) ins that is a concatenation of each word in words exactly once and w

2015-09-23 17:06:43 241

原创 LeetCode_OJ【28】Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这题虽然用朴素字符串匹配算法也能过,但是最好还是用KMP算法,毕竟笔试面试的时候可没有这么简单。KMP算法的精髓在于求出next数组,nex

2015-09-21 10:31:05 305

原创 LeetCode_OJ【29】Divide Two Integers

Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.这题运用移位轻松解决,但是要注意是否会溢出,在会不会溢出这里我卡了好久。int占4字节,表示范围为-2^31 ~ 2^31-1。程序首先要将除数与被除数都变成正数,

2015-09-21 10:12:25 241

原创 LeetCode_OJ【25】Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

2015-09-17 13:50:45 285

原创 LeetCode_OJ【24】Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You m

2015-09-17 10:52:50 261

原创 LeetCode_OJ【23】Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.这道题目一开始就弄错了思路,虽然参照了之前 LeetCode_OJ【21】Merge Two Sorted Lists 的思路来解题,却使用了错误的使用方法。错误的使用方法:对于所有给定的头结

2015-09-16 20:46:39 398

原创 LeetCode_OJ【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.本体思路:比较两个链表当前节点的val值,并将较小值添加到新链上,当其中一个链表比较完了,将另一个链表接到新链的末

2015-09-16 20:25:36 299

原创 LeetCode_OJ【19】Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l

2015-09-16 12:46:22 325

原创 LeetCode_OJ【17】Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string

2015-09-15 15:19:02 278

空空如也

空空如也

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

TA关注的人

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