725. Split Linked List in Parts
\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        vector<ListNode*> result;\n        ListNode *temp = NULL;\
```\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        vector<ListNode*> result;\n        ListNode *temp = NULL;\n        ListNode *prev = NULL;\n        ListNode *curr = head;\n        int n = 0, subPart = 0;\n        while(curr){\n            ++n;\n            curr=curr->next;\n        }\n        curr = head;\n        if(k>=n){\n            while(curr && k--){\n                temp = curr->next;\n                curr->next = NULL;\n                result.push_back(curr);\n                curr = temp;\n            }\n            temp = NULL;\n            while(k--){\n                result.push_back(temp);\n            }\n            return result;\n        }\n        while(k){\n            subPart = ceil((float)n/k);\n            //cout<<subPart<<endl;\n            n-=subPart;\n            temp = curr;\n            while(subPart--){\n                prev = temp;\n                temp = temp->next;\n            }\n            prev->next = NULL;\n            result.push_back(curr);\n            curr = temp;\n            --k;\n        }\n        return result;\n    }\n};\n```
['Linked List', 'C', 'C++']