摘要:
(1)为什么一定是三次握手,从双方的角度看,都必须构成回路,且三次为最少,所以不是两次也不是四次或以上。 (2)为什么是四次挥手,从双方的角度看,都必须构成回路,且是分别发出信号。 阅读全文
摘要:
1.HashMap引发的 (1)基于散列表实现。 (2)阈值=table数组长度*扩容因子。 (3)线程非安全。 阅读全文
摘要:
(1)结构上的: ArrayList,动态数组;LinkedList,双向链表。 (2)性能上的: ArrayList,在查找上有优势;LinkedList,在插入和删除上有优势。 阅读全文
摘要:
(1)双检查 if(instance == null){//一次检查 synchronized (MySingleton.class) { if(instance == null){//二次检查 instance = new MySingleton(); } } (2)静态代码块 private s 阅读全文
摘要:
Java代码: public static int KMP_Index(char [] s , char [] t){ int [] next = next(t); int i=0,j=0; while(i<s.length&&j<t.length){ if(j 1||s[i]==t[j]){ i+ 阅读全文
摘要:
A B C A A C B B C B A D A A B C A C B D 原始 0 0 0 0 1 1 0 0 0 0 0 1 0 1 1 2 3 4 0 0 优化 -1 0 0 -1 1 1 0 0 0 0 -1 1 -1 1 0 0 -1 4 0 0 Java代码: public stat 阅读全文
摘要:
int nCurSum=0; int nGreatestSum=-2147483648; for(int i=0;inGreatestSum) nGreatestSum=nCurSum; } 阅读全文
摘要:
public static int [] rad(String str){ StringBuilder newStr= new StringBuilder(); newStr.append('#'); for(int i=0;i<str.length();i++){ newStr.append(st 阅读全文
摘要:
for(int i=0;i<nums.length;i++){ int component = target-nums[i]; if(map.containsKey(component)) return new int[]{map.get(component),i}; map.put(nums[i] 阅读全文
摘要:
int nCurSum=0; int nGreatestSum=-2147483648; for(int i=0;i<pDate.length;i++){ if(nCurSum<=0) nCurSum=pDate[i]; else nCurSum+=pDate[i]; if(nCurSum>nGre 阅读全文