#3819
Rotate Non Negative Elements
specialist · 915 · lc medium +31 · 47.8% accepted · 74 likes · top 33%
Description
Given an integer array nums and an integer k, cyclically rotate only the non-negative values to the left by k steps. All negative elements must remain fixed at their original positions. After rotating the non-negative values, slot them back into the positions previously occupied by non-negative elements (skipping over negative positions). Return the resulting array.
Code
1
2
3