For a linked list, delete the kth to last node.
Anonymous
In swift: func deleteNodesStarting(fromIndex index : Int, linkedList : LinkedList) { var currentNode : Node? = linkedList.head var currentIndex = 0 while currentNode != nil { if index-1 == currentIndex { currentNode?.next = nil return } currentNode = currentNode?.next currentIndex += 1 } }
Check out your Company Bowl for anonymous work chats.