Easy CPP beats 100%
\n\n# Approach\n Describe your approach to solving the problem. \n## The problem can be divided into 3 simple steps =>\n\n1. Count Total Nodes\n2. Determine Par
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n## **The problem can be divided into 3 simple steps =>**\n\n1. Count Total Nodes\n2. Determine Part Sizes\n3. Split the list and store them\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> We are traversing the list twice so it is O(n).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(k) => ans vector.\n\n# Code\n```cpp []\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) {\n        ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);\n        int len = 0;\n        ListNode* temp = head;\n\n        while(temp) {\n            len++;\n            temp = temp->next;\n        }\n\n        int partSize = len / k;\n        int extra = len % k;\n\n        vector<ListNode*> ans(k, nullptr);\n\n        temp = head;\n\n        for(int i = 0; i < k && temp; i++) {\n            ans[i] = temp;\n\n            int size = partSize + ((extra > 0) ? 1 : 0);\n\n            for(int j = 0; j < size-1; j++) {\n                if(temp) {\n                    temp = temp->next;\n                }\n            }\n\n            if(temp) {\n                ListNode* nextPart = temp->next;\n                temp->next = nullptr;\n                temp = nextPart;\n            }\n\n            extra--;\n        }\n\n        return ans;\n    }\n};\n```
['Linked List', 'C++']