Is there any difference in these type of calculating ans in dynamic problems ? Because in case of Code 3 I am getting segmentation fault while Code 1 and Code 2 are passing<