Swap it (Sorting Question)
You have given a sequence of some elements p1, p2, p3, ..... pn, which is the
permutation of {1,2,3.....n}.
Rules:
You can perform at most one swapping.
Your task is to determine whether sequence can be represented in a sorted format
or not.
Solution:
Thank you so much for reading this article, if you like this question please share this with your friends who love programming. And if you have questions or feedback please drop a comment.
To solve more problems on array and string, please check out these articles "Top 10 Array Interview Questions" and "Top 10 String Interview Questions".
All the Best!
Comments
Post a Comment