Back to Browse

1089. Duplicate Zeros | LeetCode Solution

16 views
May 17, 2026
3:40

In this video, I solve LeetCode Problem 1089 β€” Duplicate Zeros using an easy and beginner-friendly approach in C++. πŸ“Œ Problem Statement: Given a fixed-length integer array arr, duplicate each occurrence of zero while shifting the remaining elements to the right. The modifications must be done in-place without returning anything. πŸ”Ή Example: Input: arr = [1,0,2,3,0,4,5,0] Output: [1,0,0,2,3,0,0,4] Explanation: Each zero is duplicated, and the remaining elements are shifted within the fixed array length. πŸ’‘ In this solution, we will: Understand the in-place array modification concept Learn how shifting elements works Handle duplicate zeros efficiently Write clean and optimized C++ code Analyze time and space complexity πŸš€ Perfect for beginners practicing: Arrays Two Pointer Technique Simulation Problems LeetCode Easy Problems C++ DSA Preparation If you found this video helpful, make sure to Like πŸ‘, Share πŸ“€, and Subscribe πŸ”” for more coding and DSA content!

Download

0 formats

No download links available.

1089. Duplicate Zeros | LeetCode Solution | NatokHD