Bug Report for https://neetcode.io/problems/two-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
this should fail for
[1,1,1,1,1,4,1,1,1,1,1,7,1,1,1,1,1]
and target 11 when code is like below for c#
public class Solution {
public int[] TwoSum(int[] nums, int target) {
var eleAndIdx = new Dictionary<int, int>();
for (int i=0; i<nums.Length; i++)
{
var complement = target - nums[i];
if (eleAndIdx.ContainsKey(complement))
{
return new int[]{eleAndIdx[complement], i};
}
else
{
eleAndIdx.Add(nums[i], i);
}
}
return new int[]{0};
}
}
as .Add() on a dictionary in c# with the same key should throw an exception
Bug Report for https://neetcode.io/problems/two-integer-sum
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
this should fail for
[1,1,1,1,1,4,1,1,1,1,1,7,1,1,1,1,1]
and target 11 when code is like below for c#
as .Add() on a dictionary in c# with the same key should throw an exception