provided solution for 18-th problem