filmov
tv
Java - right rotate array elements n times

Показать описание
Given an integer array A and an integer n, right rotate the array A n times.
Example:
A[] = {16, 10, 8, 21, 14, 7}, n = 2
Output:
A[] = {14, 7, 16, 10, 8, 21}
Using two methods
- Method 1 right rotates array A and creates a fresh new rotated array RA. Array A remains unchanged
- Method 2 right rotates array A in-place without using an auxiliary array
0:27 Problem introduction
2:11 Method 1 - right rotate array A and create a fresh new rotated array RA
10:13 Method 2 - right rotate array A in-place without using an auxiliary array
19:21 Running the code and testing
Java practice program for beginners.
Java practice program in arrays.
#javaprogramming #javatutorial #javaforbeginners
Example:
A[] = {16, 10, 8, 21, 14, 7}, n = 2
Output:
A[] = {14, 7, 16, 10, 8, 21}
Using two methods
- Method 1 right rotates array A and creates a fresh new rotated array RA. Array A remains unchanged
- Method 2 right rotates array A in-place without using an auxiliary array
0:27 Problem introduction
2:11 Method 1 - right rotate array A and create a fresh new rotated array RA
10:13 Method 2 - right rotate array A in-place without using an auxiliary array
19:21 Running the code and testing
Java practice program for beginners.
Java practice program in arrays.
#javaprogramming #javatutorial #javaforbeginners