How To Reverse An Array In JAVA | FREE DSA Course in JAVA | Lecture 63

preview_player
Показать описание
We are covering simple java operations on arrays.

In this program, we will learn how to reverse an array.

For example, we have an array, 1, 5, 6, 79, 80, 60, 23 then we must reverse the array in the sense that it now becomes 23, 60, 80, 79, 6, 5, 1

We can solve this program using loops by placing one pointer at the start of the array and another pointer at the end of the array.

All we need to do now is interchange their positions and increase the initial pointer by one and decrease the last pointer by one.

Let's check out how we can write a java program to reverse an array.

or call us at 8884881203

#java #array #arrayjava #dsa #dsacourse #placement #job
Рекомендации по теме
Комментарии
Автор

We don't need to swap we can also do these by:
for(i=A.length; i>=0;i--){
sout(A[i]);
It will take just 10 lines and also save our time.

manishachanda
Автор

Great video sir. This is very good video and please make on video on DSA topic as well.

mayureshwar
Автор

amazing explanation sir....!
this is the your first video that I'm watching... and I love it.

Nirajjha
Автор

thank you for this simplest explanation ever :)

MokshithPatel
Автор

int j = last element of array a[i] solved my problem, thanks a lot sir

mrb
Автор

what was the time & space complexity of this code ????

prashantbaghel
Автор

this is really easy to understand thank you!

romeiyu
Автор

Sir can you cover dynamic programming and make a playlist ?

bhuvaneshd
Автор

Why is easier questions being posted today ?

-Dev
Автор

we can do the same thing by using for(int i=a.length-1;i>=0;i--)
Sysout(a[i]+" ");
Why do wee need to create aethod and them calling using while??

vineethyadav
Автор

why don't you teach on board that will be easy for us to understand and i personally like more beacuse it's to irritating when u tell the concept on virtual mode. I hope u will consider my request

annu