cs110: read about complexity and some soln.