3 ms·
With a better chosen dp approach you can even solve it in O(log(n)). Though at that point the extra cost of multiplying large integers becomes non-negligible.
by contravariant 6y ago
With a better chosen dp approach you can even solve it in O(log(n)). Though at that point the extra cost of multiplying large integers becomes non-negligible.
- maxmaio 6y agoI'm having trouble coming up with this approach on my own. could you share it please?