Replace every element with its previous element by JavaScript in codezinger

Pubblicato il: 19 luglio 2022
sul canale di: TechnoPlant
290
4

Given an array A of integers, write a program to replace each element in the array by the previous element. Replace the first element by -1.

Input:
4
1 2 3 4

where:
First line represents the number of elements in the array.
Second line represents the elements in the array.


Output:

-1 1 2 3



Explanation: Every element A[i] is replaced by A[i-1]. And the first element will be -1, as the first element doesn't have any previous element.


In questa pagina del sito puoi guardare il video online Replace every element with its previous element by JavaScript in codezinger della durata di ore minuti seconda in buona qualità , che l'utente ha caricato TechnoPlant 19 luglio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 290 volte e gli è piaciuto 4 spettatori. Buona visione!