Skip to content

Latest commit

 

History

History
10 lines (7 loc) · 436 Bytes

README.md

File metadata and controls

10 lines (7 loc) · 436 Bytes

<< [35] Segregate the values of an array >>

Given an array of strictly the characters 'R', 'G', and 'B', segregate the values of the array so that all the 'R's come first, the 'G's come second, and the 'B's come last. You can only swap elements of the array. Do this in linear time and in-place.

For example:

>>> coding_problem_35(['G', 'B', 'R', 'R', 'B', 'R', 'G'])
['R', 'R', 'R', 'G', 'G', 'B', 'B']