Skip to content

Bug Report for two-integer-sum #5502

@hamza-faisal-26

Description

@hamza-faisal-26

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.

Take this test case into consideration which is NOT included during submission:
nums=[3,4,3,6]
target=9

the above test case fails
but on submission all tests passed

with this algorithm:
vector twoSum(vector& v, int target) {
vector<vector> vec;
unordered_map<int,int> m;
for (int i=0; i<v.size(); ++i) {
if (m.find(target-v[i])!=m.end()) {
vec.push_back({m[target-v[i]],i});
}
m[v[i]]=i;
}
sort(vec.begin(),vec.end());
return vec[0];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions