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

Flashcards

Pythagorean Triplet

Suhas S Inglês 1 flashcard

Flashcards do conjunto (1)

  1. 1Given an integer array find all Pythagorean triplets.static boolean isTriplet(int arr[], int n)
    {
    // Square array elements
    for (int i=0; i= 2; i--)
    {
    // To find the other two elements, start two index
    // variables from two corners of the array and move
    // them toward each other
    int l = 0; // index of the first element in arr[0..i-1]
    int r = i-1; // index of the last element in arr[0..i-1]
    while (l < r)
    {
    // A triplet found
    if (arr[l] + arr[r] == arr[i])
    return true;
    // Else either move 'l' or 'r'
    if (arr[l] + arr[r] < arr[i])
    l++;
    else
    r--;
    }
    }

Informações

Descrição
FlashCards sobre Pythagorean Triplet, criado por Suhas S em 19-03-2018.
Criado por
Suhas S
Visualizações
1
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?