Guys I am unable to figure out why I am getting SIGSEGV error in my solution:(https://ideone.com/7ndJXG) while this solution is getting accepted:(https://ideone.com/k0Slqd) Question:(http://www.spoj.com/problems/ROADS/) Basically I am unable to find the difference between the working of both functions. Any help will be appreciated..