Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Too bad the explanation is not very clear...
The description says :
"The rational given to decompose could be greater than one or equal to one, in which case the first "fraction" will be an integer (with an implicit denominator of 1)."
The test cases do not appropriately conform to the specifications of the task. For example, on input
12/4
the test expects the result[3]
, however this does not satisfy the requirement that numerators in the decomposition must equal1
. The correct result should be[1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/15, 1/230, 1/57960]
Yep, to be precise, this algorithm runs in time O(n), but the problem can be solved in O(logn).
This comment is hidden because it contains spoiler information about the solution
This problem is NP-Hard, so it's unlikely it can be made any more efficient.
This comment is hidden because it contains spoiler information about the solution
This has a runtime of O(n^2), it can be done more efficiently at O(n)