simple and easy C++ solution 😍❤️‍🔥
Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n\n# Complexity\n- Time complexity:
###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<ListNode*> splitListToParts(ListNode* head, int k) \n    {\n        // Initialize a vector to store values from the linked list\n        vector<int> value;\n\n        // Traverse through the linked list and store each node\'s value in the \'value\' vector\n        while (head) \n        {\n            value.push_back(head->val); // Add the current node\'s value to the vector\n            head = head->next; // Move to the next node\n        }\n\n        // \'n\' is the total number of nodes in the linked list\n        int n = value.size(), cur = 0;\n\n        // \'need\' is the base number of elements each part should have\n        int need = n / k;\n\n        // \'extra\' is the number of parts that need one more element\n        int extra = n % k;\n\n        // Initialize the result vector of ListNode pointers\n        vector<ListNode*> ans;\n\n        // Split the list into \'k\' parts\n        while (k--)\n        {\n            // Create a dummy node to make it easier to build the linked list part\n            ListNode* head = new ListNode(0);\n            ListNode* tail = head; // Tail will be used to append nodes to this new part\n            \n            // Add \'need\' nodes to the current part\n            int i = cur, cnt = need;\n\n            // Add \'need\' number of nodes to the current part if available\n            while (cnt-- && i < n)\n            {\n                tail->next = new ListNode(value[i++]); // Append the current node\n                tail = tail->next; // Move the tail pointer to the newly added node\n                if (cnt == 0) break; // Stop if we\'ve added the required nodes\n            }\n\n            // If there are extra nodes left, add one more node to this part\n            if (extra)\n            {\n                extra--; // Reduce the count of extra nodes\n                tail->next = new ListNode(value[i++]); // Add one extra node to the current part\n            }\n\n            // Update \'cur\' to the next position in the \'value\' vector\n            cur = i;\n\n            // Add the newly created linked list part (excluding the dummy node) to the result vector\n            ans.push_back(head->next);\n        }\n\n        // Return the vector containing the parts\n        return ans;\n    }\n};\n```\n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n
['Array', 'Linked List', 'C++']