Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int[] solution(int[] A, int K) {
- if(A == null){
- return A;
- }
- for(int y = 0; y < K; y++){
- int temp = A[A.length - 1];
- for(int x = A.length - 1; x > 0; x --){
- A[x] = A[x - 1];
- }
- A[0] = temp;
- }
- return A;
- }
- class Solution {
- public int[] solution(int[] A, int K) {
- try{
- for(int y = 0; y < K; y++){
- int temp = A[A.length - 1];
- for(int x = A.length - 1; x > 0; x --){
- A[x] = A[x - 1];
- }
- A[0] = temp;
- }
- return A;
- }
- catch(ArrayIndexOutOfBoundsException e){
- return A;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement