Tap here to switch tabs
Problem
Submissions

Problem: Rotate Non Negative Elements

Rotate Non Negative Elements asks you to shift only an array's non-negative values left by k positions while negative values keep their original indices. Return the modified array.

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

Rotate Non Negative Elements asks you to shift only an array's non-negative values left by k positions while negative values keep their original indices. Return the modified array.

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