Convert an Array Into a 2D Array With Conditions | Weekly Contest 339 | LeetCode 2610