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.
For anybody stuck on this one, they have some tricky inputs in some of the test cases. Remember that it has to print the list from least to greatest. Think about the problem like this: You know that you have some number of 'a's less than n and some number of 'b's less than n. The minimum number on the last stone would then be (n-1) * a (or b if b is less than a) and the maximum number is (n-1) * b. These can be rewritten as:
min = ((n-1)* a) + (0 * b) and vice versa. Now all you have to do is solve like so, next iteration = ((n-1-1)*a) + (1 *b) and so on. Hope this helps.
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
For anybody stuck on this one, they have some tricky inputs in some of the test cases. Remember that it has to print the list from least to greatest. Think about the problem like this: You know that you have some number of 'a's less than n and some number of 'b's less than n. The minimum number on the last stone would then be (n-1) * a (or b if b is less than a) and the maximum number is (n-1) * b. These can be rewritten as: min = ((n-1)* a) + (0 * b) and vice versa. Now all you have to do is solve like so, next iteration = ((n-1-1)*a) + (1 *b) and so on. Hope this helps.