Skip to content

Practice Transformed Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3379
LeetCode Problem

Transformed Array

Problem Statement

Treat nums as circular. Construct result independently from the original array: for each index i, move nums[i] positions right if positive, or its absolute value positions left if negative, and copy the value at the destination into result[i]. If nums[i] is zero, set result[i] to zero. Return result.

Source: Transformed Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,-2,1,1]
Output
[1,1,1,3]

# Example 2

Input
nums = [-1,4,-1]
Output
[-1,-1,4]

Constraints

1 <= nums.length <= 100
-100 <= nums[i] <= 100

Related LeetCode Problems

Practice more problems similar to Transformed Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.