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.
Manasa and Stones
Manasa and Stones
Sort by
recency
|
961 Discussions
|
Please Login in order to post a comment
My solution in C language :
The solution here is to use the absolute difference between the two differences to increment the initial value (0 + (smallest_value_between_a_and_b * (n-1))) until you reach the expected number of stones (initial value is the first stone).
We know the output as follow:
we can iterate over range 'n' and add these values to set remove duplicates.
Here is problem solution in python, Java, c++, C and Javascript - https://programmingoneonone.com/hackerrank-manasa-and-stones-problem-solution.html
python