2019-03-14 Daily Challenge

原文引用 大专栏  https://www.dazhuanlan.com/2019/08/26/5d633cc1b2327/


What I've done today is Moving Zeros To The End in JavaScript.

Problem

Moving Zeros To The End

Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.

1
moveZeros([false,1,0,1,2,0,1,3,"a"]) 

Solution

1
2
3
var moveZeros = function (arr) {
return arr.filter(a=>a!==0).concat(arr.filter(a=>a===0))
}
上一篇:30-Day Leetcoding Challenge Day22


下一篇:Codechef July Challenge 2019 MXMN