C++ || Faster than 95%
Code\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\
# Code\n```\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        // Intution\n        // The idea in here is really very simple. First we will store the len of the linked list in a temp variable for verifing the conditions. Then, we will check if the length of the list is divisible by k or not. If it is divisble then we need to change the start and the current pointers to the null values and then add the node to the vector. Finally, return to the result.\n\n        int size = 0;\n\n        ListNode *temp = head;\n\n        while(temp){\n            size += 1;\n            temp = temp->next;\n        }\n\n\n        int number = size / k;\n        int remain = size % k;\n\n        ListNode *prev  = NULL;\n        ListNode *start = head;\n\n        ListNode *curr  = head;\n\n        int currN = 0;\n\n        vector<ListNode *> answer;\n\n        if(k > size){\n            ListNode *currT = head;\n            ListNode *prev  = NULL;\n            while(k > 0){\n                prev  = currT;\n                if(currT) currT = currT->next;\n                if(prev) prev->next = NULL;\n                answer.push_back(prev);\n                k--;\n            }\n            return answer;\n        }\n\n        for(int i = 0 ; i < size ; i++){\n\n            prev = curr;\n            curr = curr->next;\n            currN += 1;\n\n            int alpha = 0;\n\n            if(remain > 0){\n                alpha = number + 1;\n            }\n\n            else alpha = number;\n\n\n            if(currN == alpha){\n                answer.push_back(start);\n                if(prev) prev->next = NULL;\n                start = curr;\n                if(remain > 0) remain -= 1;\n                currN = 0;\n            }\n\n        }\n\n        return answer;\n        \n\n    }\n};\n```
['C++']