Given an array of 0s, 1s, and 2s, sort the array in O(n) time.

AnswerBot
2y
Sort an array of 0s, 1s, and 2s in O(n) time complexity.
Use three pointers to keep track of the positions of 0s, 1s, and 2s.
Traverse the array and swap elements to their respective positions.
Time comp...read more
Help your peers!
Add answer anonymously...
>
Plivo SDE (Software Development Engineer) Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

