While following a tutorial on memoization, I encountered this strange case where the memoized function is slightly slower than the brute force version in the worst case. I'm assuming my implementation is wrong (the tutorial was in Javascript), but I can't see where. Any help would be greatly appreciated.

```
func howSum(_ targetSum: Int, _ numbers: [Int]) -> [Int]? {
if targetSum == 0 { return [] }
if targetSum < 0 { return nil }
for num in numbers {
let remainder = targetSum - num
if var results = howSum(remainder, numbers) {
results.append(num)
return results
}
}
return nil
}
func howSum(_ targetSum: Int, _ addends: [Int])-> [Int]? {
var memo: [Int: [Int]?] = [:]
func sum(_ target: Int, _ numbers: [Int]) -> [Int]? {
if let early = memo[target] { return early }
if target == 0 { return [] }
if target < 0 { return nil }
for num in numbers {
let remainder = target - num
if var results = sum(remainder, numbers) {
results.append(num)
memo[target] = results
return results
}
}
memo[target] = nil
return nil
}
return sum(targetSum, addends)
}
print(String(describing: howSum(7, [2, 3]))) //[3, 2, 2]
print(String(describing: howSum(7, [5, 3, 4, 7]))) //[4, 3]
print(String(describing: howSum(7, [2, 4]))) //nil
print(String(describing: howSum(8, [2, 3, 5]))) //[2, 2, 2, 2]
print(String(describing: howSum(300, [7, 14]))) //nil
```