The code is working fine on gdb compiler, but giving segmentation fault on lab code runner.
Res should be initialised to Null
The base case should not return Null but headRef. (*headRef = Null but not headRef itself)
The base case should not return Null but headRef. (*headRef = Null but not headRef itself)