Please read the new rule regarding the restriction on the use of AI tools. ×

Sorting Question

Revision en1, by code_fille, 2015-06-22 19:53:14

Given an array of 3 different colored balls, we have to sort it using minimum number of swaps. It could be done in O(n) using 3-pointers and two traversals(one to count no. of occurrences of each color and other to sort). Could this be implemented in one traversal(count is not known before).

Tags sorting

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English code_fille 2015-06-22 19:53:14 310 Initial revision (published)