• API
• FAQ
• Tools
• Archive
daily pastebin goal
85%
SHARE
TWEET

# Untitled

a guest Feb 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. class Solution {
2. public int[] solution(int[] A, int K) {
3.   if(A == null){
4.     return A;
5.   }
6.  for(int y = 0; y < K; y++){
7.     int temp = A[A.length - 1];
8.         for(int x = A.length - 1; x > 0; x --){
9.             A[x] = A[x - 1];
10.         }
11.         A[0] = temp;
12.     }
13.
14.     return A;
15. }
16.
17. class Solution {
18. public int[] solution(int[] A, int K) {
19.
20.
21. try{
22. for(int y = 0; y < K; y++){
23.     int temp = A[A.length - 1];
24.         for(int x = A.length - 1; x > 0; x --){
25.             A[x] = A[x - 1];
26.         }
27.         A[0] = temp;
28.     }
29.
30.     return A;
31. }
32. catch(ArrayIndexOutOfBoundsException e){
33.     return A;
34. }
35. }
36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top