Replace every element with its previous element by JavaScript in codezinger

Veröffentlicht am: 19 Juli 2022
auf dem Kanal: 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.


Auf dieser Seite können Sie das Online-Video Replace every element with its previous element by JavaScript in codezinger mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer TechnoPlant 19 Juli 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 290 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!