1. Two Sum | MOST LIKED QUESTION | coding | leetcode | citycoder

preview_player
Показать описание
Given an array of integers, return indices of the two numbers such that they add up to a specific target.

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

Example:

Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
Рекомендации по теме
Комментарии
Автор

You're awesome, Doing great work. Please keep posting more solution videos on Java/Python

mohammednaveeduddin
Автор

Thankyou for the wonderful explanation!!

anand.kumarsoni
Автор

We didnt inserted values in map table at first but directly using values from map.dont know how that is working, can someone pls explain

sahil_cse_guy
Автор

why my js code is not working

var twoSum = function(nums, target) {

for(let i=0;i<nums.length;i++)
{
for(j=i+1;j<nums.length;j++)
{

{
console.log("the indices where target matched is=");
console.log("["+i+", "+j+"]");
}
}
}
};

SouravCheck