
[Array] 배열 회전하기
·
algorithm
1차원 배열 회전하기/** * Rotate 1-dimensional Array * Time complexity: O(n) * Space complexity: O(1) * */public class Rotate { private static final Logger logger = Logger.getLogger(Rotate.class.getName()); public static void main(String[] args) { int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9}; int len = nums.length; int k = 12 % len; /* rotate right */ rotate(nums, 0,..