Skip to content
New issue

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

feat: add swift implementation to lcof2 problem: No.027 #3026

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
style: format code and docs with prettier
  • Loading branch information
klever34 authored and idoocs committed Jun 4, 2024
commit 654e77e6b16a652d66e6261ae0262e6dac4a49a7
6 changes: 3 additions & 3 deletions lcof2/剑指 Offer II 027. 回文链表/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ public class Solution {
class Solution {
func isPalindrome(_ head: ListNode?) -> Bool {
guard let head = head else { return true }

var slow = head
var fast = head.next
while fast != nil && fast?.next != nil {
slow = slow.next!
fast = fast?.next?.next
}

var cur = slow.next

var prev: ListNode? = nil
Expand All @@ -383,7 +383,7 @@ class Solution {
prev = cur
cur = nextTemp
}

var left = head
var right = prev
while right != nil {
Expand Down