We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Head needs to be updated and point where the next node is pointing.The whole idea behind using recursion is to make the problem smaller and reaching the base case.To make the problem smaller we will shift head by 1 each time and check for base case.We will do it till we reach base case execute that and return.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →
Head needs to be updated and point where the next node is pointing.The whole idea behind using recursion is to make the problem smaller and reaching the base case.To make the problem smaller we will shift head by 1 each time and check for base case.We will do it till we reach base case execute that and return.