目标:
- 每周至少做一个 leetcode 的算法题
- 阅读并点评至少一篇英文技术文章
- 学习至少一个技术技巧
- 分享一篇有观点和思考的技术文章
第二周
-
LeetCode 23
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode mergeKLists(ListNode[] lists) { if(lists.length == 0) return null; if(lists.length == 1) return lists[0]; if(lists.length == 2){ return mergeTwoLists(lists[0],lists[1]); } int mid = lists.length/2; ListNode[] first = new ListNode[mid]; for(int i = 0; i < mid; i++){ first[i] = lists[i]; } ListNode[] second = new ListNode[lists.length-mid]; for(int i = mid,j=0; i < lists.length; i++,j++){ second[j] = lists[i]; } return mergeTwoLists(mergeKLists(first),mergeKLists(second)); } private ListNode mergeTwoLists(final ListNode first, final ListNode second) { if (first == null) return second; if (second == null) return first; ListNode node = null; if (first.val < second.val) { node = first; if (first.next != null) node.next = mergeTwoLists(first.next, second); else node.next = second; } else { node = second; if (second.next != null) node.next = mergeTwoLists(first, second.next); else node.next = first; } return node; } }
-
英文技术文章点评z
最近在做蓝牙的测试工具,所以官方的蓝牙文档看得比较多
https://developer.android.com/guide/topics/connectivity/bluetooth
介绍了Android平台有关蓝牙的介绍,蓝牙api的应用,蓝牙如何连接
-
技术技巧 Java I/O
IO系统是Java中使用的了装饰者模式
-
分享一篇有观点和思考的技术文章