Skip to content

Commit

Permalink
[LinkedList] Add a solution to Reverse Nodes in k-Group
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiYue committed Feb 13, 2017
1 parent 0483037 commit ea3d7c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions LinkedList/ReverseNodesInKGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class ReverseNodesInKGroup {
for _ in 1...k {
groupTail = groupTail?.next
}
guard groupTail != nil else { // groupTail = D
guard let _ = groupTail else { // groupTail = D
break
}

let nextGroupHead = groupTail!.next // nextGroupHead = E
var last = nextGroupHead // last = E
var current : ListNode? = prev.next! // current = B
var current : ListNode? = prev.next // current = B
while current != nil && current !== nextGroupHead {
let next = current!.next // next = C
current!.next = last // B -> E
Expand Down

0 comments on commit ea3d7c1

Please sign in to comment.