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

Flashcards

Maximum sum such that no two elements are adjacent

Suhas S Inglês 1 flashcard

Flashcards do conjunto (1)

  1. 1Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Input : arr[] = {1, 2, 3} Output : 4int FindMaxAdjacentSum(int a[],int n){
    int excl = 0;
    int incl = a[0];
    for(int i = 1; i< a.length; i++){
    int excl_new = (incl>excl)?incl:excl;
    incl = excl + arr[i];
    excl = excl_new;
    }
    }

Informações

Descrição
FlashCards sobre Maximum sum such that no two elements are adjacent, criado por Suhas S em 31-03-2018.
Criado por
Suhas S
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?