You are viewing a single comment's thread. Return to all comments →
Any one knows what is wrong here? I'm getting correct answers (on some tests that I checked) but still fails Kotlin
fun removeDuplicates(llist: SinglyLinkedListNode?): SinglyLinkedListNode? { // Write your code here var currentNode = llist var firstNode = llist while (currentNode != null){ //println("Current Node: ${nextNode.data}") //println("Next Node: ${nextNode.next!!.data}") if (currentNode.next != null && currentNode.next!!.data == currentNode.data){ // duplicate, remove it var temp = currentNode.next currentNode.next = currentNode.next!!.next temp = null } else { currentNode = currentNode.next } } // println("End") //printSinglyLinkedList(firstNode, " ") return firstNode }
Seems like cookies are disabled on this browser, please enable them to open this website
Delete duplicate-value nodes from a sorted linked list
You are viewing a single comment's thread. Return to all comments →
Any one knows what is wrong here? I'm getting correct answers (on some tests that I checked) but still fails Kotlin