題解 | #牛的品種排序I#
牛的品種排序I
http://fangfengwang8.cn/practice/e3864ed7689d460c9e2da77e1c866dce
/** * 代碼中的類名、方法名、參數(shù)名已經(jīng)指定,請(qǐng)勿修改,直接返回方法規(guī)定的值即可 * * * @param cows int整型一維數(shù)組 * @return int整型一維數(shù)組 */ function sortCows( cows ) { // write code here const zeroArr = [] const oneArr = [] cows.forEach((e)=>{ if(e){ oneArr.push(e) }else{ zeroArr.push(e) } }) const ans = zeroArr.concat(oneArr) return ans } module.exports = { sortCows : sortCows };
Blog測試