LeetCode: Week 1 — Move Zeroes

Jayram Manale
2 min readApr 12, 2020

--

30-day leet coding challenge

Problem Statement :

Table of Contents:

  1. Code Solution
  2. Explanation
  3. Run Code

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 forloop

Execution Values in Each Iteration

After execution first forloop, we get nums = [1, 3, 12, 3, 12]

now, second forloop will fill the zero in the numsarray from index

Execution Values in Each Iteration

After execution second forloop, 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 :)

--

--