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 the same element twice.

Example 1:

This the frequently asked question in FANG & Top Rated Leet Code Problem.. solution in Java.

Approach-1 : Time Complexity : O(n) & Space: O(n).

This problem is to check how much good you are at data structures. Best Data Structure to solve this problem is Stack or ArrayDeque(In Java)…

Sivareddy Uppathi

Full Stack Software Developer| Programming enthusiast | Loves DS-Algo and System Design

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store