finished the coding for topcoder