daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Dec 9th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var solution = function(day, drinkingDayArr) {
  2.     var dayArr = new Array(day).fill(0)
  3.     dayArr[0] = 1
  4.     dayArr.forEach((v,i) => {
  5.         let oneDay = drinkingDayArr.shift()
  6.         if((i) === oneDay) {
  7.             dayArr[i-1] = 0
  8.             dayArr[i] = 0
  9.             return;
  10.         } else if (i > 0) {
  11.             dayArr[i] = dayArr[i-1] + 1
  12.         }
  13.         drinkingDayArr.unshift(oneDay)
  14.     })
  15.     return dayArr.reduce((a,b) => a + b)
  16. }
  17.  
  18. console.log(solution(1111111, [11,222,444,555,666]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top