Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
According to Wikipedia, a man named Narayana Pandita presented the following simple algorithm to solve this problem in the 14th century. Find the largest index k such that nums[k] < nums[k + 1]. If no such index exists, just reverse nums and done. Find the largest index l > k such that nums[k] < nums[l]. Swap nums[k] and nums[l]. Reverse the sub-array nums[k + 1:].
- Loading branch information