Тёмный

How To Left Rotate Array In Java Explained Step By Step | Hacker Rank | Java Tutorial | Code Bode 

CodeBode
Подписаться 3,5 тыс.
Просмотров 20 тыс.
50% 1

#arraysinjava #javatutorial #leftroatetarray
Hi Guyz,
In this video, we will see how to left rotate the array in java.
Algorithm :
1) Take the input array and noOfRotations (input for the number of times the array is to be rotated)
2) Take a variable rotating point = noOfRotations
3) Iterate a while loop from rotating point up to the size of the array
4) Take an output array with index i initialized to 0
5) Copy elements from input array[rotatingIndex] to the output array[i]
6) Increment rotating point and index i
7) Set rotating point back to 0
8) Iterate a while loop from rotating point up to noOfRotations
9) Copy elements from input array[rotatingIndex] to the output array[i]
10) Increment rotating point and index i
Watch the video for understanding the code step by step.
Other Playlist :
Eclipse Tutorial :
• Eclipse Tutorial
HTML Tutorial :
• Playlist
HAPPY LEARNING!

Опубликовано:

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 30   
@YeetLord666
@YeetLord666 3 года назад
This is probably the best array rotation video out there if you need to understand the underlying algorithm. Thanks!
@javokhirbozorov2120
@javokhirbozorov2120 3 года назад
Thank you very much. Exactly what I was looking for. carry on do not stop making tutorials.
@sadhamhussain1272
@sadhamhussain1272 2 года назад
Great job
@vaibhavchavan9973
@vaibhavchavan9973 Год назад
Thank you.... 🎉
@ShivamKumar-ti9fo
@ShivamKumar-ti9fo 2 года назад
waah didi wahhhhhhh
@MahendraKumar-rm2vm
@MahendraKumar-rm2vm 2 года назад
I am a noob coder but I had understood clearly mam tq❤️❤️❤️❤️❤️
@vickramreddy64
@vickramreddy64 3 года назад
Nyc explaination
@shreyassalunkhe122
@shreyassalunkhe122 2 года назад
Great Explanation...!!!!!
@gDevGuy001
@gDevGuy001 3 года назад
arey madam jab noOfRotation 2 liya h toh rotating point ko 3rd index se kaise start kr rhi ho jab ki noOfRotation=rotating point h toh index 2th se start hona chiye na
@suvasishpradhan5575
@suvasishpradhan5575 2 года назад
Nice explanation
@maheshbabunadigoti7050
@maheshbabunadigoti7050 3 года назад
Great Explanation mam...I did right rotate an array....Plz upload more videos...
@CodeBode
@CodeBode 3 года назад
Great keep learning!
@vinoj9684
@vinoj9684 3 года назад
can you share the code plz?
@vaibhavsingh2197
@vaibhavsingh2197 3 года назад
great!!!!! just loved it!!
@CodeBode
@CodeBode 3 года назад
Keep Learning!
@vaibhavsingh2197
@vaibhavsingh2197 3 года назад
Waiting for more such videos to learn
@ankitkohli727
@ankitkohli727 2 года назад
hi, used the same logic to rotate array to right but it is coming up with error, please help. import java.util.Scanner; public class LeftRotateArray { public static void main(String[] args) { int[] arr = new int[] {1,2,3,4,5}; int[] outputArray = new int[arr.length]; Scanner sc = new Scanner(System.in); System.out.println("Enter the number of rotations"); int rot = sc.nextInt(); int rotpoint = rot; int i = 0; while (rotpoint< arr.length){ outputArray[i] = arr[rotpoint]; i++; rotpoint++; } rotpoint = 0; while (rotpoint
@jpkarthick869
@jpkarthick869 3 года назад
mam can we left rotate 2d array mam
@yashjoshi5895
@yashjoshi5895 2 года назад
getting error if i accept arrray from user
@shivatapasya1910
@shivatapasya1910 Год назад
Mam please do for right rotate 🙏?
@rahulranjan5067
@rahulranjan5067 3 года назад
Very good explanation.
@CodeBode
@CodeBode 3 года назад
Thank you keep Learning!
@mokshanachannel9587
@mokshanachannel9587 3 года назад
Will this Work for right rotation
@akashmahajan1278
@akashmahajan1278 2 года назад
what if the number of rotation are more than size of array
@kunalsharma5124
@kunalsharma5124 3 года назад
Please Provide the Left Rotation Solution using List method public static List rotateLeft(int d, List arr) { // Write your code here // public static int[] rotateArray(int[] arr, int d){ // Because the constraints state d < n, we need not concern ourselves with shifting > n units. int n = arr.size(); // Create new array for rotated elements: List rotated = new ArrayList(); // Copy segments of shifted elements to rotated array: System.arraycopy(arr, d, rotated, 0, n - d); System.arraycopy(arr, 0, rotated, n - d, d); return rotated; Please correct the code and provide the Solution. I am getting runtime Error.
@volcanopz6243
@volcanopz6243 2 года назад
This is going to take o(n) space , could you please share the solution in o(1) space
@KKCodes
@KKCodes 3 года назад
Same Program Explained in hindi : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-mYPC8776dxM.html
Далее
Why the FASTEST Sorting Algorithm can(t) be O(N)!
9:41
Qizim 58-qism | Anons |Nimaga meni bolam o'ladi ?
00:47
ПОЮ НАРОДНЫЕ ПЕСНИ🪗
3:19:41
Просмотров 1,9 млн
Premature Optimization
12:39
Просмотров 774 тыс.
Shifting Arrays Left and Right with Java
17:51
Просмотров 3,6 тыс.
Java program to right rotate an Array by 3 elements
14:22
Arrays Left Rotation HackerRank Solution
11:52
Просмотров 46 тыс.
How to plan your Java learning path - Brain Bytes
16:46
Learn Java in 14 Minutes (seriously)
14:00
Просмотров 4,6 млн