The above solution uses binary tree for nth time instance i.e. -n and n. But as the level of tree increases this becomes inefficient. For values like abs(200) or more above program gives segmentation fault.
Below solution does not make a tree and takes complexity equal to exact number of steps required. Also the steps required are printed in the array which equals the exact sum required.
Find a number in minimum steps : https://www.geeksforgeeks.org/find-a-number-in-minimum-steps/