Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement