It sounds strange but I copied pasted and used the same input for the method, I get the correct result on my machine but leetcode is producing different result for the same code. this is the code on leetcode for Q-377:
class Solution:
def combinationSum4(self, nums: List[int], target: int,memo={}) -> int:
if target in memo:
return memo[target]
if target==0:
return 1
if target<0:
return 0
count=0
for num in nums:
remainder=target-num
count+=self.combinationSum4(nums,remainder)
memo[target]=count
return count
this is the result I am getting for nums=[9] target=3
this is the result on jupyter and pycharm. same code. I copied from leetcode:
I also tried this solution got same issue: