Help optimize D solution to phone encoding problem: extremely slow performace.

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue Jan 16 21:29:57 UTC 2024


On Tuesday, 16 January 2024 at 21:15:19 UTC, Renato wrote:
> I can't explain why it's so incredibly fast, specially for the 
> `count` case. I tried using the same hashing function on my 
> solution, but that didn't really help me!

That's dynamic programming with memoization. Basically caching 
the already calculated results (in the `dp` array) and avoiding 
recalculations when the recursive function revisits the same 
state again.


More information about the Digitalmars-d-learn mailing list