LinkedList in Swift

Reverse Doubly Link List.

[Question] Given a Doubly Linked List, the task is to reverse the given Doubly Linked List. Here we can can solve by two approach #1 Iterative #2 Recursive For information about usage visit my Githhub Page

Odd Even Linked List

[Question] Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. You must solve the problem in O(1) extra space complexity and O(n) time complexity. Example 1: Input: head = [1,2,3,4,5] Output: [1,3,5,2,4]

Remove Nth Node From End of LinkedList

[Question]: Given the head of a linked list, remove the nth node from the end of the list and return its head. Input: head = [1,2,3,4,5], n = 4 Output: [1,3,4,5] #Approach Two pointer Step: 1 Move fast pointer till countStep: 2 Increment fast pointer till we get fast?.next == nil if we got nil just remove mid pointer…

Delete Middle node from Single Link List

[Question]: You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.