Problem statement

https://binarysearch.com/problems/Packing-Boxes/

Solution

We can use functionality of groupby here.

Complexity

It is O(n) for time and space.

Code

class Solution:
    def solve(self, nums):
        return [list(y) for x, y in groupby(nums)]