摘要:public class Solution { public TreeNode Convert(TreeNode pRootOfTree) { if(pRootOfTree == null) return null; if(pRootOfTree.left==null&&pRootOfTree.right==null) return pRootOfTree; ...
阅读全文
摘要:public boolean VerifySquenceOfBST(int[] sequence) { if(sequence == null || sequence.length==0) return false; int start = 0, end = sequence.length-1; return helper(sequence, start, end); }...
阅读全文
摘要:public boolean IsPopOrder(int [] pushA,int [] popA) { if(pushA == null || popA==null || pushA.length==0 || pushA.length!=popA.length) { return false; } Stack stack =...
阅读全文
摘要:public static ArrayList printMatrix(int[][] matrix) { ArrayList ret = new ArrayList(); if(matrix == null||matrix.length==0||matrix[0].length==0) return ret; int m = matrix...
阅读全文
摘要:public class Solution { public void Mirror(TreeNode root) { if(root == null) return; TreeNode temp = root.left; root.left = root.right; root.right = temp; Mirror(root....
阅读全文
摘要:public class Solution { public boolean HasSubtree(TreeNode root1,TreeNode root2) { boolean ret = false; if(root1 == null || root2 == null) return ret; ret = helper(root1,root2); ...
阅读全文
摘要:脏读:(Read committed) 不可重复读:(Repeatable read) 幻读:(Serializable)
阅读全文
摘要:【GET】从指定的资源请求数据 【POST:传输实体文本】 GET方法和POST方法本质上的区别: 1、GET方法用于信息获取,它是安全的(安全:指非修改信息,如数据库方面的信息),而POST方法是用于修改服务器上资源的请求; 2、GET请求的数据会附在URL之后,而POST方法提交的数据则放置在H
阅读全文
摘要:TCP-流量控制 所谓的流量控制就是让发送方的发送速率不要太快,让接收方来得及接受。利用滑动窗口机制可以很方便的在TCP连接上实现对发送方的流量控制。TCP的窗口单位是字节,不是报文段,发送方的发送窗口不能超过接收方给出的接收窗口的数值。 TCP-拥塞控制 慢开始和拥塞避免 发送报文段速率的确定,既
阅读全文
摘要:Innodb引擎: 1.Innodb引擎提供了对数据库ACID事务的支持,并且实现了SQL标准的四种隔离级别 2.该引擎还提供了行级锁和外键约束,它的设计目标是处理大容量数据库系统,它本身其实就是基于MySQL后台的完整数据库系统 3.MySQL运行时Innodb会在内存中建立缓冲池,用于缓冲数据和
阅读全文
摘要:CDN的原理非常简单。当浏览器请求一资源时,第一步是做DNS解析,DNS解析就像是从通讯录根据姓名找号码,浏览器发送域名,然后得到DNS服务器返回的IP地址。浏览器通过IP地址和服务器连接并获取资源(DNS服务器会有很多层的缓存,但超出本文范围)。 对于小站点或个人博客,一个域名对应一个IP地址,而
阅读全文
摘要:ThreadPoolExecutor ThreadPoolExecutor#execute(Runnable command); public void execute(Runnable command) { if (command == null) throw new NullPointerExc
阅读全文
摘要:打开浏览器,输入http://zhihu.com敲回车键。 第一步是浏览器对用户输入的网址做初步的格式化检查,只有通过以上检查才会进入下一步。(如果小明输入的是 “zhi hu.com” 或 “zhi@hu.com1”, 这些网址都是非法无效的,浏览器就要拒绝小明的无理要求,提示小明出错了)浏览器是
阅读全文
摘要:public class Solution { ArrayList> res = new ArrayList(); ArrayList path = new ArrayList(); public ArrayList> FindPath(TreeNode root,int target) { if (root == null) { ...
阅读全文
摘要:常见面试题【问题1】为什么连接的时候是三次握手,关闭的时候却是四次握手? 答:因为当Server端收到Client端的SYN连接请求报文后,可以直接发送SYN+ACK报文。其中ACK报文是用来应答的,SYN报文是用来同步的。但是关闭连接时,当Server端收到FIN报文时,很可能并不会立即关闭SOC
阅读全文
摘要:public ArrayList PrintFromTopToBottom(TreeNode root) { ArrayList ret = new ArrayList(); if(root==null) return ret; Queue queue = new LinkedList(); queue.offer(root); while(queue.s...
阅读全文
摘要:public ListNode Merge(ListNode list1,ListNode list2) { if(list1==null) return list2; if(list2==null) return list1; ListNode head=new ListNode(0); ListNode current = head; ...
阅读全文
摘要:public ListNode ReverseList(ListNode head) { if(head==null||head.next==null) return head; ListNode pReverseHead=null; ListNode pNode=head; ListNode pPrev=null; while...
阅读全文
摘要:public int NumberOf1(int n) { int count = 0; while (n!=0) { n = n&(n-1); count++; } return count; }
阅读全文
摘要:public ListNode FindKthToTail(ListNode head,int k) { if(head==null) return head; ListNode pre=head; ListNode last=head; for(int i=0; i<k; i++){ if(last==null) return null; ...
阅读全文
摘要:public void reOrderArray(int [] array) { if(array==null||array.length==0) return; int start=0, end=array.length-1; while(startstart&&array[end]%2!=0) end--; if(start<end){ ...
阅读全文
摘要:public TreeNode reConstructBinaryTree(int [] pre,int [] in) { if(pre==null||in==null||pre.length!=in.length||pre.lengthpe || is>ie) return null; int val = pre[ps]; int ind...
阅读全文
摘要:public int minNumberInRotateArray(int [] array) { if(array==null||array.length==0) return -1; int start=0, end=array.length-1; int mid=start; while(array[start]>=arra...
阅读全文
摘要:public ListNode mergeKLists(ListNode[] lists) { if(lists==null||lists.length==0) return null; PriorityQueue minHeap=new PriorityQueue((o1, o1)->{ return o1.val-o2.val; ...
阅读全文
摘要:public List topKFrequent(int[] nums, int k){ List ret = new ArrayList(); if (nums==null || nums.length map = new HashMap(); for (int n:nums) map.put(n,map.getOrDefault(n,0)+1)...
阅读全文
摘要:private int minNumberInRotateArray(int [] array) { if (array == null || array.length == 0) { throw new RuntimeException("input is invalid"); } int index1 = 0;...
阅读全文
摘要:1 private int binarySearch(int[] input, int target) { 2 if (input == null) { 3 return -1; 4 } 5 6 int index1 = 0; 7 int index2 = input.length-1...
阅读全文
摘要:1 private void quickSort(int[] input, int start, int end) { 2 if (start >= end) return; 3 4 int index = partition(input, start, end); 5 6 if (index > start) { 7 ...
阅读全文