GoConqr has a new look! Let us know what you think.

Flashcards

1. Two Sum

susheel rao English 2 cards

Cards in this deck (2)

  1. 11. Two Sumclass Solution {
    public int[] twoSum(int[] nums, int target) {
    int arr[]=new int[2];
    HashMap map=new HashMap<>();
    for(int i=0;i
  2. 2167. Two Sum II - Input array is sortedclass Solution { //O(n)TC O (1)SC
    public int[] twoSum(int[] nums, int target) {
    int arr[]=new int[2];
    int left=0;
    int right=nums.length-1;
    while(left<=right)
    {
    int element=nums[left]+nums[right];
    if(element==target)
    {
    arr[0]=left+1;
    arr[1]=right+1;
    return arr;
    }else if(element>target){
    right--;
    }else{
    left++;
    }
    }
    return arr;
    }
    }

Information

Description
Flashcards on 1. Two Sum, created by susheel rao on 13/05/2020.
Created by
susheel rao
Views
2
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?