Solution: Rearrange Positive & Negative Values

Statement

Implement a function that rearranges elements in a list so that all negative elements appear to the left and all positive elements (including zero) appear to the right. It’s important to note that maintaining the original sorted order of the input list is not required for this task.

Constraints:

  • 11 \leq lst.length 103\leq 10^{3}
  • 10310^{-3} \leq lst.[i] 103\leq 10^{3}

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.