Tap here to switch tabs
Problem
Submissions

Problem: Rotate Non Negative Elements

med
30 min
Try to solve the Rotate Non Negative Elements problem.

Statement

You are given an integer array nums and an integer k.

Rotate only the non negative elements of nums to the left by k positions, while preserving the relative positions and indices of all negative elements.

Return the modified array after performing the rotation.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums[i] ≤105\leq 10^5

  • 0≤0 \leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rotate Non Negative Elements

med
30 min
Try to solve the Rotate Non Negative Elements problem.

Statement

You are given an integer array nums and an integer k.

Rotate only the non negative elements of nums to the left by k positions, while preserving the relative positions and indices of all negative elements.

Return the modified array after performing the rotation.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −105≤-10^5 \leq nums[i] ≤105\leq 10^5

  • 0≤0 \leq k ≤105\leq 10^5