Tap here to switch tabs
Problem
Submissions

Problem: Transformed Array

med
30 min
Try to solve the Transformed Array problem.

Statement

You are given an integer array nums that represents a circular array.

Create a new array result of the same length, where for each index i:

  • If nums[i] >0> 0, advance nums[i] steps to the right and set result[i] to the value at the arrival index.

  • If nums[i] <0< 0, move ∣|nums[i]∣| steps to the left and set result[i] to the value at the arrival index.

  • If nums[i] =0= 0, set result[i] to nums[i].

Return the resulting array result.

Note: A circular array wraps around continuously, meaning moving forward past the last element cycles back to the first element, and moving backward past the first element cycles to the last element.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • −100≤-100 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Transformed Array

med
30 min
Try to solve the Transformed Array problem.

Statement

You are given an integer array nums that represents a circular array.

Create a new array result of the same length, where for each index i:

  • If nums[i] >0> 0, advance nums[i] steps to the right and set result[i] to the value at the arrival index.

  • If nums[i] <0< 0, move ∣|nums[i]∣| steps to the left and set result[i] to the value at the arrival index.

  • If nums[i] =0= 0, set result[i] to nums[i].

Return the resulting array result.

Note: A circular array wraps around continuously, meaning moving forward past the last element cycles back to the first element, and moving backward past the first element cycles to the last element.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • −100≤-100 \leq nums[i] ≤100\leq 100