GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

1. Two Sum

susheel rao Englisch 2 Karten

Karten in diesem Stapel (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;
    }
    }

Informationen

Beschreibung
Karteikarten am 1. Two Sum, erstellt von susheel rao am 13/05/2020.
Erstellt von
susheel rao
Aufrufe
2
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck