Try ones more using my Hints | Easy Beginner Friendly Solution | Beats 100% 🔥🔥🔥
Hints\n- Follow the naive approach you can think\n- Get length of list\n- Create array of ListNode of length K \n- add n/k Nodes to each index of array \n    - 
# Hints\n- Follow the naive approach you can think\n- Get length of list\n- Create array of ListNode of length K \n- add n/k Nodes to each index of array \n    - Here you need to remember that n may not divisible by k and there are some remainder nodes so if that\'s the case check if (i < n%k) then add 1 extra node to ith list.\n\n# Intuition\nThe is very simple linked list breaking problem where you need to divide list in K part of equal size and since there can some more nodes the multiple of k so we need to increase length of list by one.\n\n# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(n)$$\n\n- where n is length of Linked List\n\n# Java \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[] splitListToParts(ListNode head, int k) {\n        int n = 0;\n        ListNode curr = head;\n        while(curr != null) {\n            n++;\n            curr = curr.next;\n        }\n        ListNode[] res = new ListNode[k];\n        curr = head;\n        for(int i = 0; i<k; i++) {\n            ListNode x = new ListNode();\n            ListNode y = x;\n            for(int j = 0; j<n/k; j++) {\n                y.next = curr;\n                y = curr;\n                curr = curr.next;\n            }\n            if(n%k > i) {\n                y.next = curr;\n                y = curr;\n                curr = curr.next;\n            }\n            y.next = null;\n            res[i] = x.next;\n        }\n        return res;\n    }\n}\n```\n# C++\n```\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        int n = 0;\n        ListNode* curr = head;\n        while (curr != nullptr) {\n            n++;\n            curr = curr->next;\n        }\n        vector<ListNode*> res(k, nullptr);\n        curr = head;\n        for (int i = 0; i < k; i++) {\n            ListNode* x = new ListNode(0);\n            ListNode* y = x;\n            for (int j = 0; j < n / k; j++) {\n                y->next = curr;\n                y = curr;\n                curr = curr->next;\n            }\n            if (n % k > i) {\n                y->next = curr;\n                y = curr;\n                curr = curr->next;\n            }\n            y->next = nullptr;\n            res[i] = x->next;\n        }\n        return res;\n    }\n};\n\n\n```\n
['Linked List', 'Python', 'C++', 'Java']