🔥🔥||  Beats 100% , Easy Solution || Traverse || 🔥🔥
\n\n# Approach\nTraverse till (a-1)th node and till (b+1)th node ,\n(a-1).next= head of list2 \ntail of list2.next =(b+1)th node\n\n\nin the code head1 is nothi
\n\n# Approach\nTraverse till (a-1)th node and till (b+1)th node ,\n(a-1).next= head of list2 \ntail of list2.next =(b+1)th node\n\n\nin the code head1 is nothing but (b+1)th node and (a-1)th node is stored in list1 , rearrange variable names according to your convenience\n\n# Complexity\n- Time complexity: O(b + list2.length)\n\n- Space complexity: O(1)\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n        int c=1;\n        int d=1;\n        ListNode head1=list1;\n        ListNode head=list1;\n        while(d<=b){\n            head1=head1.next;\n            d++;\n        }\n        if(head1.next!=null) head1=head1.next;\n        while(c<a){\n            list1=list1.next;\n            c++;\n        }\n        ListNode head2=list2;\n        while(list2.next!=null){\n            list2=list2.next;\n        }\n        list1.next=head2;\n        list2.next=head1;\n        return head;\n    }\n}\n```
['Two Pointers', 'Java']