code implementaion for questions on leecode