Skip to content

Commit 3e7c68a

Browse files
committed
Time: 314 ms, Memory: 40.3 MB - LeetHub
1 parent 66fe2a3 commit 3e7c68a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

duplicate-zeros/duplicate-zeros.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Solution {
2+
public void DuplicateZeros(int[] arr) {
3+
for (var i = 0; i < arr.Length - 1; i++)
4+
{
5+
if (arr[i] != 0)
6+
{
7+
continue;
8+
}
9+
10+
for (var j = arr.Length - 1; j >= i + 1; j--)
11+
{
12+
arr[j] = arr[j - 1];
13+
}
14+
15+
i++;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)