Java Solution (little rusty but not bad specially back to coding after few years), please suggest and motivate me :)


#1
public ArrayList<Integer> rotateArray(ArrayList<Integer> A, int B) {
   ArrayList<Integer> ret = new ArrayList<Integer>();
  
  if(A.isEmpty() || B < 1 )  {
       return ret;
   }
   
   if(B > A.size()) {
      B = B % A.size();
   }
   
   // lets put all the item from right of > B 
    for (int i = 0; i < A.size() - B; i++) {
        ret.add(A.get(i + B));
    }

    // append items from left of < B
    for(int i =0; i< B; i++) {
        ret.add(A.get(i));
    }
    
    return ret;
}