Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

876. 链表的中间结点 #11

Open
Labels
@Geekhyt

Description

@Geekhyt

原题链接

快慢指针

老套路,借助快慢指针,fast 一次走两步,slow 一次走一步,当 fast 到达链表末尾时,slow 就处于链表的中间点了。

constmiddleNode=function(head){letfast=head,slow=head;while(fast&&fast.next){slow=slow.next;fast=fast.next.next;}returnslow;};
  • 时间复杂度: O(n)
  • 空间复杂度: O(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp