滴滴社招

国际化安全

一面

项目

用到的中间件

基础知识

更新数据库,刷新缓存,通知下游,怎么保持一致性

futuretask

代码

反转链表

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.

class Node {
    int val;
    Node next;
}

public Node reverse(Node head) {

    Node prev = null;
    Node cur = head;

    while (cur != null) {
        Node next = cur.next;
        cur.next = prev;
        prev = cur;
        cur = next;
    }

    return prev;
}

void main() {
    //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
    // to see how IntelliJ IDEA suggests fixing it.

    Node head = new Node();
    head.val = 1;
    Node head1 = new Node();
    head1.val = 2;
    Node head2 = new Node();
    head2.val = 3;
    head.next = head1;
    head1.next = head2;

    Node ans = reverse(head);

    for (Node p = ans; p != null; p = p.next) {
        System.out.println(p.val);
    }

}

用本地IDE写的,不知道IDEA试用期有多久,一会我搞个盗版装上吧。

赞赏