C++ two pass solution
Approach 1: Seperate the nodes into k sections of equal size\n\nStep 1: Count how many nodes are in the linked list\n- Knowing how many nodes are in the linked 
# Approach 1: Seperate the nodes into k sections of equal size\n\n**Step 1: Count how many nodes are in the linked list**\n- Knowing how many nodes are in the linked list is critical to solving this question\n- Once we know how many nodes are in the linked list we can start caluclating the size of each group\n- The code below is the process for counting nodes in a linked list\n```\nListNode* itr = head;\nint count = 0;\nwhile (itr) {\n    count++;\n    itr = itr->next;\n}\n```\n**Step 2: Count how many should be in each section, and how many additional there are**\n- The amount of nodes in each group is equal to (how many nodes / k). This gives us how many nodes can fit into k groups, where each group size is equal\n- The additional nodes is equal to (how many nodes % k)\n- See the example below illustrating these caluclations\n```\nk = 3\n1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10\n\ncount = 10\n\nequal group size = 10 / 3 = 3\nadditional = 10 % 3 = 1\n\n```\n**Step 3: Initialize output vector and pointers to be used, find first seperation point**\n- intialzing an output vector of ListNodes is required for the output\n- To seperate nodes we will need a trailing node (prev) and a leading node (curr). This is because singly linked lists to do not have access to their previous node, therefore a trailing node will allow us to unlink the current node when required.\n- the example below demonstrates the use of the trailing node\n```\n"we want to seperate at node 3"\nt = trailing pointer\nl = leading pointer\n\n"we need to get out leading pointer to three, the trailing will be one node behind"\n\n1 -> 2 -> 3 -> 4\n     t    l\n\n"unlink 2 from 3 by removing the connection of the trailing node"\n1 -> 2    3 -> 4\n     t    l\n\n"after unlinking we still have access to the rest of the LL as we did not manipulate any connections from 3 onwards"\n```\n\n- We also need to find the first seperation point\n- this is done through the code below\n```\n// finding first seperation point\nint next_start = amount + (additional > 0 ? 1 : 0);\nif (additional > 0) {\n    additional--;\n}\n```\n- we had previously found amount and additional nodes\n- if additional is > 0, we want one extra node in this group (since we are filling from left to right of the LL). We also need to decrement the additional nodes remaning after this.\n\n**Step 4: Loop through linked list and seperate when neccesary**\n- using the group sizes we found, the additional nodes and also the process of seperation the following code will seperate the nodes into their correct k groups\n ```\n// loop through all "count" number of nodes\n for (int i = 0; i < count; i++) {\n            // if we are at a seperation point\n            if (i == next_start) {\n                prev->next = nullptr; // unlink the previous (trailing pointer)\n                output.push_back(curr); // add this starting node into out output vector\n\n                // calculate next seperation point\n                next_start += amount + (additional > 0 ? 1 : 0);\n                if (additional > 0) {\n                    additional--;\n                }\n            }\n            // increment pointers\n            prev = curr;\n            curr = curr->next;\n            \n            // case to handle the start of the LL\n            if (i == 0) {\n                output.push_back(head);\n            }\n        }\n```\n\n**Additional Step: if we still have left over spaces fill with nullptrs**\n- if k was larger then the input size, we will need to fill in the final (k - input size) spaces in the output vector with null ptrs\n\n```\nwhile (output.size() < k) {\n    output.push_back(nullptr);\n}\n```\n# Complexity\n**Time complexity: O(n)**\n- we do 2 traversals of the input linked list of size n = O(2n) = O(n)\n\n**Space complexity: O(1) (output vector is not included in calculation)**\n- we only use a constant amount of variables for this soloution\n# 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        if (!head) return vector<ListNode*>(k, nullptr); // if nullptr return empty vector of size k\n        \n        /* Step 1: Count how many nodes are in the linked list*/\n        ListNode* itr = head;\n        int count = 0;\n        while (itr) {\n            count++;\n            itr = itr->next;\n        }\n        \n        /* Step 2: Count how many should be in each section, and how many additional there are*/\n        int amount = count / k;\n        int additional = count % k;\n        \n        /* Step 3: Initialize output vector and pointers to be used, find first seperation point, */\n        \n        vector<ListNode*> output; // output vectpr\n        ListNode* curr = head; // leading pointer\n        ListNode* prev = nullptr; // trailing pointer\n        \n        // finding first seperation point\n        int next_start = amount + (additional > 0 ? 1 : 0);\n        if (additional > 0) {\n            additional--;\n        }\n        \n        /* Step 4: Loop through linked list and seperate when neccesary*/\n        for (int i = 0; i < count; i++) {\n            // if we are at a seperation point\n            if (i == next_start) {\n                prev->next = nullptr; // unlink the previous (trailing pointer)\n                output.push_back(curr); // add this starting node into out output vector\n\n                // calculate next seperation point\n                next_start += amount + (additional > 0 ? 1 : 0);\n                if (additional > 0) {\n                    additional--;\n                }\n            }\n            // increment pointers\n            prev = curr;\n            curr = curr->next;\n            \n            // case to handle the start of the LL\n            if (i == 0) {\n                output.push_back(head);\n            }\n        }\n        \n        // Additional Step: if we still have left over spaces fill with nullptrs\n        while (output.size() < k) {\n            output.push_back(nullptr);\n        }\n        \n        return output;\n    }\n};\n\n```
['C++']