Skip to content

Commit d448088

Browse files
Duplicate zeros
1 parent c151ec9 commit d448088

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

1089

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Duplicate Zeros
2+
3+
/**
4+
* @param {number[]} arr
5+
* @return {void} Do not return anything, modify arr in-place instead.
6+
*/
7+
var duplicateZeros = function(arr) {
8+
for(i=0;i<arr.length;i++){
9+
if(arr[i] === 0){
10+
for(j=arr.length-1;j>i;j--){
11+
arr[j] = arr[j-1];
12+
}
13+
i++;
14+
}
15+
}
16+
};

readMe.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Let me know what you think and how you can help
2424
| 557 | Reverse Words in a String III | String | Easy |
2525
| 665 | Non-decreasing Array | Array | Medium |
2626
| 906 | Sort Array By Parity | Array | Easy |
27+
| 1089 | Duplicate Zeros | Array | Easy |
2728
| 1287 | Element Appearing More Than 25% In Sorted Array | Array | Easy |
2829
| 1394 | Find Lucky Integer in an Array | Array | Easy |
2930
| 1450 | Number of Students Doing Homework at a Given Time | Array | Easy |
@@ -40,4 +41,4 @@ Let me know what you think and how you can help
4041
| 2665 | Counter II | Array | Easy |
4142
| 2667 | Create Hello World Function | .. | Easy |
4243

43-
Total Solved 33 Problems.
44+
Total Solved 34 Problems.

0 commit comments

Comments
 (0)