LeetCode: Week 1 — Move Zeroes
2 min readApr 12, 2020
30-day leet coding challenge
Problem Statement :
Table of Contents:
Code Solution:
Time Complexity: O(n) | Space Complexity: O(1)
Explanation:
we’ll be trying to understand the solution code with its execution values for each Iteration.
let's start with first for
loop
After execution first for
loop, we get nums = [1, 3, 12, 3, 12]
now, second for
loop will fill the zero in the nums
array from index
After execution second for
loop, we get nums = [1, 3, 12, 0, 0]
as the expected result.
Run Code:
You can also check out other problem solution below
I hope you enjoy this solution. Let me know if you have any other solutions in response. Cheers :)