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.
- Prepare
- Algorithms
- Recursion
- K Factorization
- Discussions
K Factorization
K Factorization
Sort by
recency
|
48 Discussions
|
Please Login in order to post a comment
My answer in Typescript, note includes.
note: it is a litte confuse when Q ask me to print -1 but my code required to return [-1] insteads
Simple solution
Find the factor
I tried using Greedy approach and it passes all the tests (java)
That's rather sloppy of them. The greedy algorithm fails on e.g. making 84 from [2, 3, 7, 12, 14], since the optimal factorization is 7*12 which you can't find if you start by selecting 14; you'd think they'd include some such tests.
Thanks, Alex! I almost missed this for my greedy python solution. Indeed very sloppy - this task needs new tests.
Here is K Factorization problem solution in Python Java c++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-k-factorization-problem-solution.html