Simple easy and beginner friendly code for daily challenge
\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\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        \n        vector<ListNode*> ans;\n        \n        \n        int n = 0;\n        \n        ListNode* temp = head;\n        \n        while(temp!=NULL){\n            n++;\n            temp = temp->next;\n        }\n       \n        if(n<k){\n            ListNode* Nodeptr = head;\n            \n            while(Nodeptr!=NULL){\n                ListNode* dummy = new ListNode(Nodeptr->val);\n                ans.push_back(dummy);\n                Nodeptr = Nodeptr->next;\n            }\n            \n            for(int i=0;i<k-n;i++){\n                ans.push_back(NULL);\n            }\n        }\n        else{\n            int noOfListWithExtraElement = n%k;\n            int noOfElements = n/k;\n            \n            ListNode* Nodeptr = head;\n            \n            for(int i=0;i<noOfListWithExtraElement;i++){\n                ListNode* dummy = new ListNode(-1);\n                \n                ListNode* newhead = dummy;\n                \n                for(int j=0;j<noOfElements+1;j++){\n                    dummy->next = new ListNode(Nodeptr->val);\n                    Nodeptr = Nodeptr->next;\n                    if(Nodeptr==NULL){\n                        break;\n                    }\n                    dummy = dummy->next;\n                }\n                \n                // if(Nodeptr==NULL){\n                //     break;\n                // }\n                \n                ans.push_back(newhead->next);\n            }\n            \n            for(int i=0;k - noOfListWithExtraElement;i++){\n                ListNode* dummy = new ListNode(-1);\n                \n                ListNode* newhead = dummy;\n                \n                for(int j=0;j<noOfElements;j++){\n                    dummy->next = new ListNode(Nodeptr->val);\n                    Nodeptr = Nodeptr->next;\n                    if(Nodeptr==NULL){\n                        break;\n                    }\n                    dummy = dummy->next;\n                }\n                \n                if(Nodeptr==NULL){\n                    ans.push_back(newhead->next);\n                    break;\n                }\n                \n                ans.push_back(newhead->next);\n            }\n        }\n        \n        return ans;\n    }\n};\n```\n\nPlease upvote if you like the solution
['Linked List', 'C']