You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Question- Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.Assume there is only 1 solution .
class Solution {
public int[] twoSum(int[] nums, int target) {
int[] answer = new int[2];
// Two for loops for selecting two numbers and check sum equal to target or not
for(int i = 0; i < nums.length; i++){
for(int j = i+1; j < nums.length; j++) {
// j = i + 1; no need to check back elements it covers in i;