摘要: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C pr 阅读全文
posted @ 2017-09-22 23:09 immjc 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Note:The input is assumed to be a 32-bit signed integer. Yo 阅读全文
posted @ 2017-09-22 21:49 immjc 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-09-22 21:42 immjc 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 给定一个字符串,要求把字符串前面的若干字符移动到字符串尾部。 解法一:蛮力法 首先想考虑将一个字符移到尾部的方法。代码如下: 如果要移动m个字符串,则依次对函数LeftShiftOne执行m次即可。代码如下: 时间复杂度:将一个字符移动到尾部需要n次操作,如果要移动m个字符,则需要操作m * n次。 阅读全文
posted @ 2017-09-22 21:41 immjc 阅读(149) 评论(0) 推荐(0) 编辑