Python3 | Explained | Easy to Understand
Python3 | Explained | Easy to Understand\n\nclass Solution(object):\n    def splitListToParts(self, root, k):\n        # Count the length of the linked list\n  
# Python3 | Explained | Easy to Understand\n```\nclass Solution(object):\n    def splitListToParts(self, root, k):\n        # Count the length of the linked list\n        curr, length = root, 0\n        while curr:\n            curr, length = curr.next, length + 1\n        # Determine the length of each chunk\n        chunk_size, longer_chunks = length // k, length % k\n        res = [chunk_size + 1] * longer_chunks + [chunk_size] * (k - longer_chunks)\n        # Split up the list\n        prev, curr = None, root\n        for index, num in enumerate(res):\n            if prev:\n                prev.next = None\n            res[index] = curr\n            for i in range(num):\n                prev, curr = curr, curr.next\n        return res\n```
['Python', 'Python3']