06 2015 档案
摘要:```Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattene...
阅读全文
摘要:首先向Doug Lea致敬。# CLH以下是CLH锁的一个简单实现:```javaclass SimpleCLHLock { /** * initialized with a dummy node */ private Node dummy = new Node(); ...
阅读全文
摘要:# Java 线程状态定义都在Thread.State里,通过线程对象的`getState()`可以获取得到。## NEW新创建的还没有启动的线程所处的状态。## RUNNABLE在JVM中正在执行的线程的状态。也不一定是正在执行代码,也可能是在处于一个等待调度以获取CPU的状态,不过一般这个调度时...
阅读全文
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].```java...
阅读全文
摘要:##DESCIRPTIONImplement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, /...
阅读全文
摘要:##deploy 只上传了pom晚上输命令,打算打包上传到本地库里,然后去服务器上部署新版本```mvn clean package deploy```结果看着mvn的build过程只是上传了pom,去库服务器看了也只有pom文件,这让人相当懊恼。翻来覆去,突然看到项目pom文件里``` X-Pro...
阅读全文
摘要:###泛型不协变数组是协变的,即如果Integer是Number的子类型,则Integer[]也是Number[]的子类型```javaInteger[] is = new Integer[] {1, 2, 3};Number[] ns = is;ns[0] = new Integer(0);ns[...
阅读全文
摘要:用于绘制一些数据图,同学推荐的,挺好用。非常好的官网文档:http://matplotlib.org/contents.html0. 安装可以直接pip install,还有一些依赖就按照提示来吧,具体也忘了。1. 基本画图import matplotlib.pyplot as pltxs = [1...
阅读全文
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.强行解:inline bool valueSame(double a, double b) { re...
阅读全文
摘要:有这样一个场景存在一个model类如果User,这里省略了getter/setter方法class User { String name; String uuid; Long created; Long updated; Attr attr;}class Attr { ...
阅读全文
摘要:Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can f...
阅读全文
摘要:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed...
阅读全文
摘要:Given two words (beginWordandendWord), and a dictionary, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only on...
阅读全文
摘要:Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjac...
阅读全文
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Definition for a binary tree node...
阅读全文
摘要:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()...
阅读全文
摘要:参考:http://blog.csdn.net/finewings/article/details/5718133字符串提取去掉指定前缀1. ${varible#pattern} 从头开始,左往右,删除最短的一个pattern结尾的字符串,即截取第一个pattern结尾子串之后的字符串...
阅读全文
摘要:Implement a basic calculator to evaluate a simple expression string.The expression string may contain open(and closing parentheses), the plus+or minus...
阅读全文
摘要:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ...
阅读全文
摘要:写服务端程序,在开发环境下打开远程调试还是非常有用的,还原现场非常容易,让请求方再发个请求即可。如果下来本地调试的话很多环境与管理服务的地址配置什么的都可能不一样,增加了可变因素。在需要启动服务调试的jvm启动参数中加入(注意:参数要排在启动类名的前面)-Xdebug -Xrunjdwp:trans...
阅读全文
摘要:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except...
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr...
阅读全文
摘要:Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo...
阅读全文
摘要:Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d...
阅读全文
摘要:背景项目中需要通过一些自定义的组件来操控hive的元数据,于是使用了remote方式来存储hive元数据,使用一个服务后台作为gateway,由它来控制hive元数据。现象在windows上连接hive metastore的时候,无端的会报NullPointerException,非常费解。分析看了...
阅读全文
摘要:curl命令用来做HTTP协议的客户端,可以通过命令参数生成各种请求,非常强大。1. GET默认情况下下curl执行的是GET操作,所以可以当做wget使用如$ curl https://www.baidu.com 现在百度使用了https协议,但是这个结果还是有点奇怪...
阅读全文