complete solution, refelction and driver code updated