We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
用快慢指针
function findMid (head) { let slow = head let fast = head while (fast.next && fast.next.next) { slow = slow.next fast = fast.next.next } const newHead = slow.next // 后半段拆出来 slow.next = null // 将链表切断,把前半段拆出来 return newHead // 后半段是 newHead,前半段是 head }
画个图就懂了
function reverseList (head) { let initHead = head let pre = head while (initHead && initHead.next) { const node = initHead.next initHead.next = initHead.next.next node.next = pre pre = node } return pre }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
找链表的中间值
用快慢指针
反转链表
画个图就懂了
The text was updated successfully, but these errors were encountered: