2610. Convert an Array Into a 2D Array With Conditions

Medium

Python Solution

from copy import deepcopy as copy # importing it for deep copy

class Solution(object):
    def findMatrix(self, nums):
        container = []
        while len(nums) != 0:
            temp = copy(nums) # deep copy of nums
            new_arr = []
            for i in nums:
                if i not in new_arr:
                    new_arr.append(i) # appending the number to the new array
                    temp.remove(i) # removing the number from the temp array
                else:
                    continue

            container.append(new_arr)
            nums = temp # assigning temp to nums
        return container

Explanation

this not the best solution. it can be done in a better way. but this is what i came up with.