Skip to content

Commit ee4192f

Browse files
authored
Update js codes.docx
1 parent 9f36058 commit ee4192f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

js codes.docx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,22 @@ function MissingElements(arr)
12081208
}
12091209
}
12101210
MissingElements([1,2,6]); //3,4,5
1211+
---------------------------------------------
1212+
function MissingElements(arr)
1213+
{
1214+
for(let i = 0; i < arr.length; i++)
1215+
{
1216+
if (arr[0] != arr[i] - i)
1217+
{
1218+
while (arr[0] < arr[i] - i)
1219+
{
1220+
console.log(arr[0]+i);
1221+
arr[0]++;
1222+
}
1223+
}
1224+
}
1225+
}
1226+
MissingElements([1,2,6])
12111227
================================================================================================================================================================================
12121228
Code 84: Adding an elements to the array when elements are consecutive numbers
12131229
const as = [1,2,3,4];

0 commit comments

Comments
 (0)