/** * 贪心算法 */ const shareCookie = (g = [1,4,5,8], s = [1,3,8]) => { let index = 0 for(let i = 0; i < s.length; i++ ){ if(s[i] >= g[index]){ index++ } } return index }