Sort an Array with One Misplaced Element

Given an integer array nums. The array is almost sorted: there is at most one element such that, after removing that element, all remaining elements are in non-decreasing order.

Sort nums and...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: