Interview Machine Code Round: File Explorer
https://www.youtube.com/watch?v=20F_KzHPpvI&t=119s
const arr =[0,3,0,10,0,2] //3,10,2,0,0,0
const ans=[];
for( let i=0; i< arr.length ;i++){
if(arr[i]!==0){
ans.push(arr[i])
}
}
if(ans.length !==arr.length){
let getremanining= arr.length -ans.length;
for(let i=0;i <getremanining ;i++){
ans.push(0);
}
}
console.log(ans)
Comments
Post a Comment