题解 | 小红的环形数组

小红的环形数组

https://www.nowcoder.com/practice/2094caa98e9c40fa8da8436ee7e232c6

A = list(map(int, input().split(" ")))
n = A[0]
o = A[1]
nums = list(map(int, input().split(" ")))
for i in range(o):
    operate = input().split(" ")
    start = int(operate[0])
    step = int(operate[2])
    if operate[1] == "R":
        num = (step + start - 1)%n
    elif operate[1] == "L":
        num = (start - step - 1)%n
    print(nums[num])

全部评论

相关推荐

点赞 评论 收藏
分享
季桑陌:这怎么看是不是外包啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务