Not getting the output


getting wrong ans, please check if my approach is correct or not and whats wrong in my code

Updated ur code: