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.
if you get weight k you get all toys with weight k to k+4 free. if k is the lowest value in the array and you want to get all the toys you must buy it becuase there is no k less then the min you can buy and then get min weight free. once you buy the min then you never need to buy toys with wieght min to min+4 so you can remove these from the array. since we have to buy the lowest weight in the remainging array to have all the toys. its a recursive reductive proof.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Priyanka and Toys
You are viewing a single comment's thread. Return to all comments →
if you get weight k you get all toys with weight k to k+4 free. if k is the lowest value in the array and you want to get all the toys you must buy it becuase there is no k less then the min you can buy and then get min weight free. once you buy the min then you never need to buy toys with wieght min to min+4 so you can remove these from the array. since we have to buy the lowest weight in the remainging array to have all the toys. its a recursive reductive proof.