We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Delete duplicate-value nodes from a sorted linked list
Delete duplicate-value nodes from a sorted linked list
Sort by
recency
|
921 Discussions
|
Please Login in order to post a comment
This C++ solution mirrors the Python logic and is clean, robust, and handles corner cases well (e.g., duplicates at the start). Memory is handled with a dummy pointer to help simplify pointer rewiring. Betbricks7 com sign up
Hello I tried to solve this with kotlin cause Im Software android Engineer and I feel more familiar with kotlin
My logic is correct but Hacker rank has a kind of bug working with nulleables types the same logic in python works correctly why?
My Java solution with o(n) time complexity and o(1) space complexity:
def removeDuplicates(llist): # Write your code here var=llist while var: if var.next and var.data == var.next.data: var.next = var.next.next else: var = var.next return llist
python
def removeDuplicates(llist): # Write your code here temp=llist while temp and temp.next: if(temp.data==temp.next.data): delnode=temp.next temp.next=temp.next.next del delnode else: temp=temp.next return llist