上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页

2013年12月21日

java 总结

摘要: equals vs == equals : always remember to override hashCode if you override equals so as not to "break the contract". if equals. the hashCode must be same.== : it returns true if both variables refer to the same object, if their references are one and the same.why in the abstract class, can 阅读全文

posted @ 2013-12-21 08:07 brave_bo 阅读(297) 评论(0) 推荐(0)

2013年12月13日

多线程

摘要: Thread safety A piece of code is thread-safe if it only manipulates shared data structures in a manner that guarantees safe execution by multiple threads at the same time. #include int increment_counter (){ static int counter = 0; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZ... 阅读全文

posted @ 2013-12-13 06:03 brave_bo 阅读(172) 评论(0) 推荐(0)

2013年12月11日

design a text edit

摘要: rope (data structure) + KMP(string search) O(m+n) 阅读全文

posted @ 2013-12-11 03:17 brave_bo 阅读(173) 评论(0) 推荐(0)

局部内部类为什么只能访问final局部变量?

摘要: 局部内部类为什么只能访问final局部变量?分类:Java2012-01-07 14:03874人阅读评论(1)收藏举报stringthreadclassjava[html]view plaincopy//只有定义成finalStringobj才不会报错publicvoidtest(finalStringobj){ThreadmyThread=newThread(){publicvoidrun(){System.out.println(obj);}};myThread.start();}[html]view plaincopypublicclassOuterClass{publicvoidou 阅读全文

posted @ 2013-12-11 02:50 brave_bo 阅读(495) 评论(0) 推荐(0)

2013年10月24日

why java not support the multitude inheritance

摘要: In an white paper titled “Java: an Overview” byJames Gosling in February 1995 gives an idea on why multiple inheritance is not supported in Java.JAVA omits many rarely used, poorly understood, confusing features of C++ thatin our experience bring more grief than benefit. This primarily consists ofope 阅读全文

posted @ 2013-10-24 04:39 brave_bo 阅读(291) 评论(0) 推荐(0)

roman 数字

摘要: 羅馬數字(Roman Numbers)羅馬字數字羅馬字數字羅馬字數字羅馬字數字I1XI11XXI21C100II2XII12XXIX29CI101III3XIII13XXX30CC200IV4XIV14XL40D500V5XV15XLVIII48DC600VI6XVI16IL49CM900VII7XVII17L50M1000VIII8XVIII18LX60MDCLXVI1666IX9XIX19XC90MCMLXX1970X10XX20XCVIII98 阅读全文

posted @ 2013-10-24 04:29 brave_bo 阅读(462) 评论(0) 推荐(0)

2013年9月20日

交差方向遍历bfs 树

摘要: import java.util.ArrayList;import java.util.LinkedList;import java.util.List;import java.util.Queue;import java.util.Stack;enum Dirction {left , right} public class Tree { private BinaryTreeNode root; private List list = new ArrayList(); Dirction current = Dirction.right; ... 阅读全文

posted @ 2013-09-20 05:40 brave_bo 阅读(221) 评论(0) 推荐(0)

2013年9月9日

linkedlist 最难题 Insert into a Cyclic Sorted List

摘要: Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted li... 阅读全文

posted @ 2013-09-09 05:38 brave_bo 阅读(362) 评论(0) 推荐(0)

洗牌 算法

摘要: 1. for i:=1 to n do swap(a[i], a[random(1,n)]); // 凑合,但不是真正随机2. for i:=1 to n do swap(a[i], a[random(i,n)]); // 真正的随机算法其中,random(a,b)函数用于返回一个从a到b(包括a和b)的随机整数。2)的时间复杂度O(n), 空间复杂度O(1); 阅读全文

posted @ 2013-09-09 05:02 brave_bo 阅读(161) 评论(0) 推荐(0)

Maximum Depth of Binary Tree

摘要: Maximum Depth of Binary TreeMaximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Solution - RecursionThe recursion algorithm is easy to come up:Perform a DFS (depth-fi 阅读全文

posted @ 2013-09-09 03:45 brave_bo 阅读(157) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页

导航