Skip to content

Missing Test Case - 1. Two Sum #32471

@thejaswinikm

Description

@thejaswinikm

LeetCode Username

Thejaswini_k_m

Problem Number, Title, and Link

  1. Two Sum https://leetcode.com/problems/two-sum/

Bug Category

Problem description

Bug Description

The function returns the wrong indices for some inputs.
Steps:
Input: [3,2,4], target = 6 → Expected [1,2] but got [0,1].
Expected: Correct indices of the numbers that sum to the target.

Language Used for Code

Python/Python3

Code used for Submit/Run operation

class Solution:
    def twoSum(self, nums, target):
        hashmap = {}
        for i, num in enumerate(nums):
            diff = target - num
            if diff in hashmap:
                return [hashmap[diff], i]
            hashmap[num] = i

Expected behavior

Case 1
Case 2
Case 3
Input
nums =
[2,7,11,15]
target =
9
Output
[0,1]
Expected
[0,1]

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions