first solve the problem then write the code

first solve the problem then write the code