Ai
2 Star 1 Fork 1

望曦开源团队/Python案例合集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
LeftRotate-3.py 460 Bytes
一键复制 编辑 原始数据 按行查看 历史
NineSenz-九练 提交于 2023-04-26 00:00 +08:00 . 数组翻转指定个数的元素
def rverseArray(arr, start, end):
while (start < end):
temp = arr[start]
arr[start] = arr[end]
arr[end] = temp
start += 1
end = end-1
def leftRotate(arr, d):
n = len(arr)
rverseArray(arr, 0, d-1)
rverseArray(arr, d, n-1)
rverseArray(arr, 0, n-1)
def printArray(arr):
for i in range(0, len(arr)):
print (arr[i], end=' ')
arr = [1, 2, 3, 4, 5, 6, 7]
leftRotate(arr, 2)
printArray(arr)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangxios/workspace_Python.git
git@gitee.com:wangxios/workspace_Python.git
wangxios
workspace_Python
Python案例合集
master

搜索帮助