Coded the solution plus testcase