My sollution is not working could u please check it

Kartik I would suggest you to go through the online video lecture


and then try to implement your solution using this only.