leetcode 日经贴,Cpp code -Rotate Array
来源:互联网 发布:dos操作系统和windows 编辑:程序博客网 时间:2024/05/01 22:45
Rotate Array
class Solution {public: void reverse(int nums[], int st, int ed) { while (st < ed) { int k = nums[st]; nums[st] = nums[ed]; nums[ed] = k; ++st; --ed; } } void rotate(int nums[], int n, int k) { k = k % n; if (k == 0) return ; reverse(nums, 0, n - 1 - k); reverse(nums, n - k, n - 1); reverse(nums, 0, n - 1); }};
0 0
- leetcode 日经贴,Cpp code -Rotate Array
- leetcode 日经贴,Cpp code -Rotate Image
- leetcode 日经贴,Cpp code -Merge Sorted Array
- Leetcode 189. Rotate Array (Easy) (cpp)
- leetcode 日经贴,Cpp code -Remove Duplicates from Sorted Array II
- leetcode 日经贴,Cpp code -Product of Array Except Self
- [leetcode][array] Rotate Array
- leetcode 日经贴,Cpp code -Permutations
- leetcode 日经贴,Cpp code -Gray Code
- leetcode 日经贴,Cpp code -Convert Sorted Array to Binary Search Tree
- LeetCode[Array]: Rotate Image
- LeetCode:Rotate Array
- [LeetCode] Rotate Array
- *LeetCode-Rotate Array
- [LeetCode]189.Rotate Array
- Rotate Array - LeetCode - Java
- Rotate Array--Leetcode(Java)
- Leetcode--Rotate Array
- 杭电 HDU 2674 N!Again
- Mac 安卓开发adb整合
- js-json---各种格式数据格式提要
- wait_timeout和interactive_timeout区别
- 欢迎使用CSDN-markdown编辑器
- leetcode 日经贴,Cpp code -Rotate Array
- Anniversary party(树形DP)
- Android出现Could not find ***.apk!错误
- Git之忽略文件(ignore file)
- web开发优秀的参考资源
- Hibernate VS iBATIS
- InstrumentDriver,对iOS自动化测试说 Yes!
- char* a 与 char a[] 以及常量指针,指针常量
- Interview Question Collection