摘要:
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]. Not 阅读全文
摘要:
给定一个字符串,要求把字符串前面的若干字符移动到字符串尾部。 解法一:蛮力法 首先想考虑将一个字符移到尾部的方法。代码如下: 如果要移动m个字符串,则依次对函数LeftShiftOne执行m次即可。代码如下: 时间复杂度:将一个字符移动到尾部需要n次操作,如果要移动m个字符,则需要操作m * n次。 阅读全文