国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

[LintCode] Delete Node in the Middle of Singly Li

lowett / 667人閱讀

Problem

Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.

Note

就是把node.next.val賦給node,然后刪掉node.next,用node直接連接node.next.next

Solution
public class Solution {
    public void deleteNode(ListNode node) {
        if (node == null) return;
        if (node.next != null) {
            node.val = node.next.val;
            node.next = node.next.next;
        }
        return;
    }
}

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/65536.html

相關文章

  • [Lintcode] Nth to Last Node in List 鏈表倒數第N個節點

    摘要:遞歸法復雜度時間空間思路當遞歸到鏈表尾部時返回,每次返回時長度加,一旦長度為時記錄下該節點。雙指針法復雜度時間空間思路用兩個指針,快指針先走步,然后快慢指針同時開始走,保持的距離,這樣當快指針到達末尾時,慢指針就是倒數第個。 Nth to Last Node in List Find the nth to last element of a singly linked list. ...

    CoXie 評論0 收藏0
  • [LintCode/LeetCode] Nth to Last Node in List

    摘要:依然是一道找倒數第個結點的鏈表題,用雙指針做。先走,然后和一起走,直到為,的位置就是倒數第個位置。 Problem Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List 3->2->1->5->null ...

    Salamander 評論0 收藏0
  • [LintCode/LeetCode] Add Two Numbers

    Problem You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1s digit is at the head of the list. Write a f...

    hedzr 評論0 收藏0
  • [LintCode/LeetCode] Intersection of Two Linked Lis

    Problem Write a program to find the node at which the intersection of two singly linked lists begins. Example The following two linked lists: A: a1 → a2 ↘ ...

    OldPanda 評論0 收藏0
  • [LeetCode/LintCode] Odd Even Linked List

    Problem Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. Example Example:Given...

    awokezhou 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<