2113. Elements in Array After Removing and Replacing Elements
Содержание
class Solution:
def elementInNums(self, nums: List[int], queries: List[List[int]]) -> List[int]:
n, m = len(nums), len(queries)
res = [-1] * m
for j, (t, i) in enumerate(queries):
t %= 2 * n
if t < n and i < n - t:
res[j] = nums[i + t]
elif t > n and i < t - n:
res[j] = nums[i]
return res