Java || 1000% beats ❤️❤️ || 0(N) || 3 Solution || Easy || ❤️❤️
Intuition\n Describe your first thoughts on how to solve this problem. \nPLEASE UPVOTE ME \u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\n\n# Approach\n Descr
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nPLEASE UPVOTE ME \u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:0(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\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 curr = list1;\n        ListNode NewNode1 = list1;\n        ListNode NewNode2 = list1;\n        \n        for(int i=0; i<b; i++){\n            if(i==a-1)  NewNode1 = curr;\n            curr = curr.next;\n        }\n        NewNode2 = curr.next;\n        NewNode1.next = list2;\n        while(list2.next!=null){\n            list2 = list2.next;\n        } \n        list2.next = NewNode2;\n        return list1;\n   \n      \n//         Another solution\n\n        // int count = 0;\n        // ListNode curr = list1;\n        // ListNode newVal = null;\n        // while(curr!=null){\n        //     if(count==b) newVal = curr.next;\n        //     count++;\n        //     curr = curr.next;\n        // }\n        // curr = list1; count=0;\n        // while(curr!=null){\n        //     count++;\n        //     if(count==a) curr.next = list2;\n        //     curr = curr.next; \n        // }\n        // curr = list1;\n        // while(curr.next!=null){\n        //     curr = curr.next;\n        // }\n        // curr.next = newVal;\n        // return list1;\n    }\n}\n//     same approach but using for loop\n\n        // ListNode head = list1;\n        // for(int i = 1; i < a; i++) {\n        //     head = head.next;\n        // }\n        // ListNode temp = head;\n        // for(int i = 0; i < b-a+2; i++) {\n        //     temp = temp.next;\n        // }\n        // ListNode temp2 = list2;\n        // while(temp2.next != null) {\n        //     temp2 = temp2.next;\n        // }\n        // head.next = list2;\n        // temp2.next = temp;\n        // return list1;\n\n        \n```
['Java']