Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhipeng committed Apr 24, 2019
1 parent deeac5a commit 6b7b6f9
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions problems/279.perfect-squares.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,6 @@ for (let i = 1; i <= n; i++) {
* Output: 2
* Explanation: 13 = 4 + 9.
*/

const mapper = {};

function d(n, level) {
if (n === 0) return level;

let i = 1;
const arr = [];

while (n - i * i >= 0) {
const hit = mapper[n - i * i];
if (hit) {
arr.push(hit + level);
} else {
const depth = d(n - i * i, level + 1) - level;
mapper[n - i * i] = depth;
arr.push(depth + level);
}
i++;
}

return Math.min(...arr);
}
/**
* @param {number} n
* @return {number}
Expand Down

0 comments on commit 6b7b6f9

Please sign in to comment.