leet code solution from sandy qi