Runtime error during solution run


#1

My code: http://ideone.com/zcEcw3

Could you help me with a testcase?


#2
cur = cur->next;
if(cur->val == prev->val){

cur->next might be NULL
and you are trying to read NULL->val, this will give a seg fault

A simple c++ soln : https://ide.geeksforgeeks.org/u7bmaR2LNA