# 恢复博客更新 --- 逆序单项链表 要求空间复杂度o(1) 时间复杂度o(n)

1. 复习微积分

2. 复习概率论和统计学

3. 刷一遍leetcode

 1 package com.autonavi.algo;
2
4
5     public static void main(String[] args){
6         Node node0 = new Node(null,0);
7         Node node1 = new Node(null,1);
8         Node node2 = new Node(null,2);
9
10         node0.next = node1;
11         node1.next = node2;
12
13         Node node = node0;
14         while(null != node){
15             System.out.println(node.value);
16             node = node.next;
17         }
18
20
22         while(null != node){
23             System.out.println(node.value);
24             node = node.next;
25         }
26     }
27
28     public static Node reverse(Node head){
29         Node p;
32         while(tmp != null){
33             p = tmp;
34             tmp = tmp.next;
37         }
39     }
40 }
41
42 class Node{
43     Node next;
44     int value;
45     Node(Node next, int value){
46         this.next = next;
47         this.value = value;
48     }
49     @Override
50     public String toString() {
51         return "Node [next=" + next + ", value=" + value + "]";
52     }
53
54 }

posted @ 2016-03-01 16:26  蟹粉小笼包  阅读(681)  评论(1编辑  收藏