Solution 1

  • TimeO(n)
  • SpaceO(n)

where, n is the length of nums
Solved in 14 mins, all by yourself! Good job!

Python · 2026-02-05
class Solution:
    '''
    Time Complexity: O(n)
    Space Complexity: O(n)
    where, n is the length of nums
    Solved in 14 mins, all by yourself! Good job!
    '''
    def constructTransformedArray(self, nums: List[int]) -> List[int]:
        n = len(nums)
        result = [0]*n

        for i, num in enumerate(nums):
            p = i + num
            p = p % n
            result[i] = nums[p]
        return result
Leet Code/python.py · L5021–5037