2014年4月18日
摘要: http://blog.csdn.net/fightforyourdream/article/details/12900751 阅读全文
posted @ 2014-04-18 15:04 wf110 阅读(255) 评论(0) 推荐(0) 编辑
摘要: charTables数组记录字符对应的位置。public class Solution { public int lengthOfLongestSubstring(String s) { if(null==s||0==s.length()) return 0; ... 阅读全文
posted @ 2014-04-18 10:43 wf110 阅读(229) 评论(0) 推荐(0) 编辑
  2014年4月17日
摘要: 四舍五入保留小数点 1 方法一: 2 double myNum2 = 111231.5585478; 3 java.math.BigDecimal b = new java.math.BigDecimal(myNum2); 4 double myNum3 = b.setScale(4, ja... 阅读全文
posted @ 2014-04-17 16:52 wf110 阅读(378) 评论(0) 推荐(0) 编辑
  2014年4月15日
摘要: http://wsmajunfeng.iteye.com/blog/1492316可重入锁ReentrantLock的含义是:当某个线程获取某个锁后,在未释放锁的情况下,第二次再访问该锁锁定的另一代码块时,可以重新进入该块。什么情况下可以使用ReentrantLock:1,先看看synchroniz... 阅读全文
posted @ 2014-04-15 20:11 wf110 阅读(220) 评论(0) 推荐(0) 编辑
  2014年4月14日
摘要: 1 class Info 2 { 3 private T var; 4 5 public T getVar() { 6 return var; 7 } 8 9 public void setVar(T var) {10 this.... 阅读全文
posted @ 2014-04-14 10:46 wf110 阅读(278) 评论(0) 推荐(0) 编辑
  2014年4月11日
摘要: 每个对象都有一内置锁wait方法 释放对象锁(不占对象锁)sleep方法不释放对象锁(占对象锁)优秀写法 (下面写法可能有问题,synchronized (LOCK) 提到 while前面就好了) 1 class Info { 2 String printStr = "i think thi... 阅读全文
posted @ 2014-04-11 11:02 wf110 阅读(7975) 评论(0) 推荐(0) 编辑
  2014年4月10日
摘要: [leetcode]Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return 阅读全文
posted @ 2014-04-10 10:36 wf110 阅读(309) 评论(0) 推荐(0) 编辑
  2014年4月3日
摘要: XMLHttpRequest 对象用于和服务器交换数据。向服务器发送请求如需将请求发送到服务器,我们使用 XMLHttpRequest 对象的 open() 和 send() 方法:xmlhttp.open("GET","test1.txt",true);xmlhttp.send();方法描述ope... 阅读全文
posted @ 2014-04-03 17:03 wf110 阅读(191) 评论(0) 推荐(0) 编辑
  2014年3月29日
摘要: 1 public class MyHeapSort { 2 3 private static void OutPrint(int nums[]) 4 { 5 for(int i:nums) 6 System.out.print(i+" "); 7 System.out.println(); 8 } 9 public static void main(String[] args) {10 int numbers[]=new int[]{1,5,2,7,4,2,8,34};11 ... 阅读全文
posted @ 2014-03-29 15:25 wf110 阅读(173) 评论(0) 推荐(0) 编辑
  2014年3月21日
摘要: 这里使用BFS来解本题,BFS需要使用queue来保存neighbors但这里有个问题,在clone一个节点时我们需要clone它的neighbors,而邻居节点有的已经存在,有的未存在,如何进行区分?这里我们使用Map来进行区分,Map的key值为原来的node,value为新clone的node,当发现一个node未在map中时说明这个node还未被clone,http://oj.leetcode.com/problems/clone-graph/ 1 public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {... 阅读全文
posted @ 2014-03-21 18:45 wf110 阅读(321) 评论(0) 推荐(0) 编辑