Sunday, April 12, 2015

HackerRank::Algorithms::Warmup::Manasa and Stones

  There are many ways we can change the numbers and simple checking all the ways will take too long, but we need to notice one thing. No matter how we move we make N-1 moves and every time we change the number either by A or B, which means that the final number is going to be a sum of N-1 numbers which are either A or B. Which means in total there are N-1 possible outcomes where there are X As,  ( 1<=X<=N-1) and N-1-X Bs.



No comments:

Post a Comment