Rotate an array of n elements to the right by k steps.
For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this PRoblem.
[show hint]
Related problem: Reverse Words in a String II
Credits: Special thanks to @Freezen for adding this problem and creating all test cases.
Subscribe to see which companies asked this question.
思路:《程序员编程艺术第一~二十七章集锦与总结(教你如何编程)(by_July)定稿版》原题 计算公式:(X^tY^t)^t = YX;
新闻热点
疑难解答