Skip to content

Instantly share code, notes, and snippets.

@teyyihan
Last active December 9, 2020 10:50
Show Gist options
  • Save teyyihan/62299dee0629428f85d084ea5598707e to your computer and use it in GitHub Desktop.
Save teyyihan/62299dee0629428f85d084ea5598707e to your computer and use it in GitHub Desktop.
func memoFib(num int, d map[int]int) int {
if num <= 1 {return 0}
if num == 2 {return 1}
if val, ok := d[num]; ok {
return val
}
d[num] = memoFib(num-1,d)+memoFib(num-2,d)
return d[num]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment