DEV Community

Aniket Kadam
Aniket Kadam

Posted on

Easier Dynamic Programming with Kotlin auto-memoized functions

A common theme in programming questions for interviews is a Dynamic Programming question.
This kind of question is something that would require a huge number of calculations, but mostly of the same values, over and over again.
Generally the way to solve these efficiently is to store the previous result of calculating them and return those if we have it, which greatly reduces the number of calculations you have to do.

The process of storing what you've previously calculated is called memoization. Pretty close to memorization, in spelling and meaning, but not the same word!

An easy way to do this, is to look at this article about Kotlin Purity and Function Memoization by Jorge Castillo who's really skilled at pushing the limits of functional programming.

Have you solved algorithmic questions using functional programming and memoization in Kotlin? Let me know in the comments!

Top comments (0)