Easy Java Solution with 1ms runtime
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nstep1:\n  first take tail and head of list2 to attach between list1\n  fi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nstep1:\n  first take tail and head of list2 to attach between list1\n  first loop is used to find tail of list2\n------\nstep2:\n  we need to attach list2 at position a-1 and b+1 to make list in     between \n2 for loops are used to find ath and bth position \n------\nstep3:\n   just we need to attach list2 at ath and bth position\n   observe the postion given in digram and attach them\n   ath-->head of list2  then tail2-->bth \nthen return the list1\n------\n   \n  \n\n\n# Complexity\n- Time complexity:\nO(n)+O(a-1)+O(b+1)\nn:size of list 2\n- Space complexity:\n    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        ListNode tail2=list2,head2=list2;\n        while(tail2.next!=null){\n            tail2=tail2.next;\n        }\n        ListNode ath=list1,bth=list1;\n        for(int i=0;i<a-1;i++){\n            ath=ath.next;\n        }\n        for(int i=0;i<b+1;i++){\n            bth=bth.next;\n        }\n        ath.next=head2;\n        tail2.next=bth;\n        return list1;\n\n        \n        \n    }\n}\n```
['Java']