BEST C++ solution || Beginner-friendly approach with explanation || O(N) time
\n\n# Code\n\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        // create an empty vector of size k\n        v
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        // create an empty vector of size k\n        vector<ListNode*> ans(k);\n\n        // Count the length of the LL\n        int count = 0;\n        ListNode *temp = head;\n        while(temp != NULL){\n            temp = temp->next;\n            count++;\n        }\n        \n        // Here, extra is the number of extra nodes not multiple of k\n        // max is the number of elements in every LL\n        // index is index for ans array\n        int extra = count%k, max = count/k, index = 0;\n        temp = head;\n        // Traverse the array, form LL of size val and add it to the ans array\n        while(temp != NULL){\n            ListNode *currHead = temp;\n            int val = (extra--) > 0 ? max+1 : max, i = 0; \n            while(temp != NULL && ++i < val){\n                temp = temp->next;\n            }\n            ListNode *nextHead = temp->next;\n            temp->next = NULL;\n            temp = nextHead;\n            ans[index++] = currHead;\n        }\n        return ans;\n    }\n};\n```
['Linked List', 'C++']