Problem List
Time performance came in around the 19th percentile, which is really back. Too many nested scans. Memory was solid, 97th percentile not that it matters much. It did the job but had no hustle. In future solutions, I’ll switch to the cleaner two-pointer method that moves non-zeros forward directly and leaves zeros behind.
O(n²) Double nested for loop.O(1)func moveZeroes(nums []int) {
for i := range(nums) {
if nums[i] == 0 {
j := i
for nums[j] == 0 && j < len(nums) - 1 {
j++
}
nums[i], nums[j] = nums[j], nums[i]
}
}
}