SAIC interview question

Code basic algorithms in python