摘要: 选了个先转换成字符串,然后再翻转的做法,虽然效率不差,但属实有点拉,贴代码 class Solution { public: char* inttoString(int a,char* b) { int t = a/10; if(t!=0) { b = inttoString(a/10,b) +1; 阅读全文
posted @ 2021-03-07 18:37 zhaohhhh 阅读(42) 评论(0) 推荐(0)
摘要: 就这? class Solution { public: void reverseString(vector<char>& s) { int n = s.size(); int i = 0; int j = n-1; while(i<j) { swap(s[i++],s[j--]); } } }; 阅读全文
posted @ 2021-03-07 17:13 zhaohhhh 阅读(33) 评论(0) 推荐(0)
摘要: 旋转图像,想到的方法是以每一圈为单位,进行圈上的元素的旋转,完成每一个圈的旋转之后,就完成了整体的旋转,思路不困难,难度在于旋转时变量下标的确定,刚开始走了很多弯路,后来发现一定要把具体的数值写出来,找到不变的量,使其清晰起来,就会好搞很多,贴代码 class Solution { public: 阅读全文
posted @ 2021-03-07 11:06 zhaohhhh 阅读(70) 评论(0) 推荐(0)