Тёмный

Java Program to Rotate the elements of an array to the left By N times | Interview Question Answers 

CloudTech
Подписаться 33 тыс.
Просмотров 16 тыс.
50% 1

In this video, we demonstrated how to Rotate the elements of an array to the left By N times.
Input Array - {1 2 3 4 5}
N - 3
Output Array - {4 5 1 2 3}
#java
#javacoding
#javainterviewquestions
#javaprogramming
#coding

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

 

6 дек 2022

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 7   
@yashogg
@yashogg Год назад
Can we use queue where we pop the first element and push It to the end
@geddadapandu6683
@geddadapandu6683 Год назад
Nice bro
@kalvakolusubhash4010
@kalvakolusubhash4010 Год назад
package arrays; public class RotateArray { public static void main(String[] args) { // TODO Auto-generated method stub int[] arr = {1, 2, 3, 4, 5, 6, 7,8}; int val = 12; if (val == 0) return; int n = arr.length; // in case the rotating factor is // greater than array length val = val % n; System.out.println(val); removeElement(arr, 0, val - 1); removeElement(arr, val, n - 1); removeElement(arr, 0, n - 1); printArray(arr); } private static int[] removeElement(int[] arr, int start, int end) { // TODO Auto-generated method stub int temp; while (start < end) { temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; } return arr; } private static void printArray(int[] arr) { // TODO Auto-generated method stub for(int i=0;i
@saoae1931
@saoae1931 Год назад
int arr[]={1,2,3,4,5}; int n=3; for(int i=0;i
@farazmusic5916
@farazmusic5916 10 месяцев назад
in second for loop at the loop end you use "i++" instead of "j++" . correct it and rerun you got the output
@rajumanepalli8862
@rajumanepalli8862 Год назад
public class Main{ public static void main(String[] args) { int[] raju= new int[] {1,2,3,4,5}; int n=3; for(int i=0;i
@abhijitpanigrahi4947
@abhijitpanigrahi4947 5 дней назад
public class Practice { public static void main(String[] args) { int[] raju= new int[] {1,2,3,4,5}; int n=3; for(int i=0;i
Далее
Infosys Java Coding Round
12:43
Просмотров 212 тыс.
Premature Optimization
12:39
Просмотров 774 тыс.
Java program to right rotate an Array by 3 elements
14:22