lintcode solutions in python