O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

Search rotated array

Suhas S Inglês 1 flashcard

Flashcards do conjunto (1)

  1. 1Search rotated arrayclass Solution {
    public int search(int[] nums, int target) {
    int low = 0, high = nums.length - 1;
    int x = target;
    while(low <= high){
    int mid = (low+high)/2 ;
    if(nums[mid] == x ) return mid;
    if( nums[mid] <= nums[high]){
    if(x > nums[mid] && x <= nums[high]){
    low = mid + 1;
    }else
    high = mid - 1;
    }else if(nums[mid] >= nums[low]){
    if(x >= nums[low] && x < nums[mid] ){
    high = mid - 1;
    }else
    low = mid + 1;
    }
    }
    return -1;
    }
    }

Informações

Descrição
FlashCards sobre Search rotated array, criado por Suhas S em 12-02-2018.
Criado por
Suhas S
Visualizações
11
Tags
arrays
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?