Given an array of randomly arranged lower case letters , uppercase letters, and numbers.
How can I sort the array such that all lower case letters come before all uppercase letters, come before all numbers? The classes of characters do not need to be in order in their respective sections.
MUST RUN IN O(n) time, and O(1) space. Obviously can't use build in sort function.
My instant reaction is to looping through the string 3 times for example below.
var newArr = [];
for x in oldArr
if x is lowercase
newArr.add(x)
for x in oldArr
if x is uppercase
newArr.add(x)
for x in oldArr
if x is number
newArr.add(x)
But this uses O(n) memory.