ARTS-第二周挑战

  1. Algorithm:每周至少做一个 leetcode 的算法题

    reverse linked list(翻转链表)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode reverseList(ListNode head) {
if(head == null || head.next == null)
return head;
List<ListNode> tempList = new ArrayList<ListNode>();
reverseList(head,head.next,tempList);
return tempList.get(0);
}

public static ListNode reverseList(ListNode currentNode, ListNode nextNode,List objList) {
ListNode changedNextNode;

if (nextNode.next == null) {
objList.add(nextNode);
changeNodeOrder(currentNode,nextNode);
return currentNode;
} else {
changedNextNode = reverseList(nextNode, nextNode.next,objList);
}

changeNodeOrder(currentNode, changedNextNode);
return currentNode;

}

public static void changeNodeOrder(ListNode prevNode, ListNode nextNode) {
nextNode.next = prevNode;
prevNode.next = null;
}
}
  1. Review:阅读并点评至少一篇英文技术文章

    自己翻译练习的Effective Java (注:翻译水平很有限,欢迎大家指正),第二篇未完待续。。。

    Effective Java Item01_静态工厂方法

  2. Tip:学习至少一个技术技巧

    英语语法句子的形成名词作主语

  3. Share:分享一篇有观点和思考的技术文章

    架构01_架构到底指什么