Friday, July 24, 2015

HackerRank::Algorithms::Greedy::Two Arrays

   Greedy again, which means we need to be as greedy as we can and in this case greediness would be spending as little "resources" as possible in order to save the best for the last. For every element from A we need to find a pair from B where their sum will be more or equal than K, so fro every I, we need to try to find the smallest B which will satisfy the condition, by picking this way we will find a valid solution for sure (if the solution exists) , if we can't find anything than simply the answer is NO>


No comments:

Post a Comment