Skip to content
RED SAG Skills
hard20 pts · first answer countsdynamic-programmingmemoizationdebugging

Memo that never hits in JavaScript

This memoised JavaScript function is as slow as plain recursion. Why?

const memo = new Map()
function f(i, j) {
  const key = [i, j]
  if (memo.has(key)) return memo.get(key)
  // ... compute r
  memo.set(key, r)
  return r
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions