C++ Super Simple and Short Explained Solution, 4ms Faster than 97%
Idea:\nFirst, we count the nodes using helper function countNodes.\nNow, we know that each part_size will be n / k, and the first left parts will have part_size
**Idea:**\nFirst, we count the nodes using helper function `countNodes`.\nNow, we know that each `part_size` will be `n / k`, and the first `left` parts will have `part_size + 1`.\nIn each iteration, we set `res[i]` to be our current node, and then move `head` as far as we need for this part - `part_size + (i < left)`.\nWe keep the `prev` to be able to split the parts.\n\n**Time Complexity:** O(n)\n**Space Complexity:** O(1)\n\n```\nclass Solution {\npublic:\n    int countNodes(ListNode* head) {\n        int n = 0;\n        while (head) {\n            n++;\n            head = head->next;\n        }\n        return n;\n    }\n    \n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        int n = countNodes(head);\n        int part_size = n / k, left = n % k;\n        ListNode *ptr = head, *prev = NULL;\n        \n        vector<ListNode*> res(k);\n        for (int i = 0; i < k; i++) {\n            res[i] = head;\n            \n            for (int j = 0; j < part_size + (i < left); j++) {\n                prev = head; \n                head = head->next; \n            }\n            if (prev) prev->next = NULL;\n        }\n        \n        return res;\n    }\n};\n```\n**Like it? please upvote!**
['C']