It is not working for left and up case showing segmentation.I dont understand the problem

Here is my code

hi @riagoel3999 check if sol is not 1 else it will come back and forth,
refer
https://ide.codingblocks.com/s/667008