Implemented TopCoder tutorial problem