For example, to give change for $0.72, choose a quarter, that leaves $0.47. Choose a quarter again, that leaves $0.22. Choose a dime twice, then two pennies. This is a total of 5 coins, and that's the fewest coins possible to give change for $0.72.
The greedy approach doesn't work if you're missing coins: for example, to give change for $0.32 if you're out of nickels. A greedy approach would choose a quarter (maximal/largest coin) and seven pennies for eight total coins. But three dimes and two pennies makes change with five coins.
First you'll read the APT and come up with a plan for determining how to "steal" votes and from whom you should steal them. Think about whether a greedy approach will work and if so, why. Then you'll think about how to implement a solution using helper methods/code to facilitate writing a short, understandable solution.
You can try to analyze this numerically, or you can effectively simulate the candle lighting by choosing a candle to light (or two, or three, and so on) and then "lighting" them by shortening them appropropriately. How do you choose which to light and how do you simulate this?
This one looks tricky at first, where do you begin? You need to analyze
which period is best, or tree each of the periods from 1 to
maxPeriod
. But how do you change the periodic chunks of DNA
so that they are identical? Which nucleotide/AGTC in each
chunk do you change to be like another? One key idea here is
to realize that for each chunk, the first character must be
the same in all the chunks if the chunks are to match. If
you're going to change the first character of each chunk, what
character should you change it to? How do you calculate this?
If you repeat this process for each of the p-characters in a chunk when the period is p, you can determine how many changes are needed to ensure all chunks are the same. Do this for each chunk size and you'll be on the way to getting this.