Java - Mod based solution. Simple Logic!


#1
public class Solution {
public ArrayList<Integer> rotateArray(ArrayList<Integer> A, int B) {
	ArrayList<Integer> ret = new ArrayList<Integer>();
	int count = 0;
	int modValue = B%A.size();
	B = modValue;

	for (int i = 0; i < A.size(); i++) {
		if((i+B)>=A.size()){
			ret.add(A.get(count++));
			continue;
		}
		ret.add(A.get(i + B));
	}
	return ret;
}

}