My first approach was to create count
and left_arr
varaible to store my valid count and left split.
I then iterated through the array, stopping at the second-to-last index. This is because a valid split must leave at least one element on the right side. At each iteration, I appended the current element (nums[i])
to left_arr
, gradually building the left portion of the split. To define the right portion, I took a slice of the array starting from the next index (i + 1)
to the end, ensuring the right side always included all elements after the split point.