We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functioncheckEnergy(n,arr){leten=n;for(leti=0;i<arr.length;i++){en=2*en-arr[i];if(en<0)returnfalse;}returntrue;}functionchiefHopper(arr){// Write your code hereif(checkEnergy(arr[0],arr)){leti=arr[0]-1;while(checkEnergy(i,arr)){i--;}i++;returni;}else{leti=arr[0]+1;while(!checkEnergy(i,arr)){i++;}returni;}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Chief Hopper
You are viewing a single comment's thread. Return to all comments →
Just brute force