Saturday, 28 September 2013

Separate the alphabet and digit such that their relative order remains the same in O(n) time and O(1) space

Separate the alphabet and digit such that their relative order remains the
same in O(n) time and O(1) space

Given an array [a1b7c3d2] convert to [abcd1732] with 0(1) space and O(n)
time i.e. put the letters on the left and digits on the right such that
their relative order is the same. I can think of an O(nlogn) algorithm,
but not better. Can somebody please help?

No comments:

Post a Comment