simple clear solution🎯💯c++👑O(n)🫡
\n\n\n# Code\ncpp []\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        vector<ListNode*> result(k, nullptr);\
![Screenshot 2024-09-08 at 6.48.07\u202FAM.png](https://assets.leetcode.com/users/images/ff78a4e6-8476-4640-9a88-fff138bd99aa_1725758329.7289941.png)\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        vector<ListNode*> result(k, nullptr);\n        ListNode* curr = head;\n        int totalLength = 0;\n\n        // Step 1: Calculate the total length of the list\n        while (curr) {\n            totalLength++;\n            curr = curr->next;\n        }\n\n        // Step 2: Determine the size of each part\n        int partSize = totalLength / k;\n        int extraNodes = totalLength % k;\n\n        curr = head;\n        for (int i = 0; i < k && curr; ++i) {\n            result[i] = curr;\n            int currentPartSize = partSize + (extraNodes > 0 ? 1 : 0);\n            extraNodes--;\n\n            // Step 3: Move to the end of the current part\n            for (int j = 1; j < currentPartSize; ++j) {\n                curr = curr->next;\n            }\n\n            // Step 4: Break the link for the current part\n            ListNode* nextPart = curr->next;\n            curr->next = nullptr;\n            curr = nextPart;\n        }\n\n        return result;\n    }\n};\n\n```
['C++']