codegamy_logo

CODEGAMY

1. Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use thesame element twice.

You can return the answer in any order.

Input Format

  • First line will contain T, number of testcases. Then the testcases follow
  • The first line in each testcase contains an array of integers nums seperated by space
  • The next line contains one integer target
  • Output Format

  • One line with array of two integers
  • Sample Input

    3
    2 7 11 15
    9
    3 2 4
    6
    3 3
    6

    Sample Output

    0 1
    1 2
    0 1

    Constraints:

  • 2 ≤ nums.length ≤ 10
  • -10 ≤ nums[i] ≤ 10
  • -10 ≤ target ≤ 10
  • Only one valid answer exists.
  • Submission Info

    User Accepted

    19509

    User Tried

    19509

    Total Accepted

    19509

    Total Submissions

    19509

    Difficulty

    Easy
    Python
    Dark
    14

    Custom Input

    Output

    2024 © Codegamy | All Rights Reserved.

    Developed by QUAD ❤️