Solution for implementing three stacks in one array