add solution using stack