You are viewing a single comment's thread. Return to all comments →
def atNodeFromTail(head,position): cur = head stack = [] while cur != None: stack.append(cur.data) cur = cur.next return stack[-position-1]
Simple Solution with O(N) complexity
https://github.com/shahiakhilesh1304/DSA/blob/main/Solution/Question16/SolutionScreenShots/image.png
For the reference of the code
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Get Node Value
You are viewing a single comment's thread. Return to all comments →
Simple Solution with O(N) complexity
https://github.com/shahiakhilesh1304/DSA/blob/main/Solution/Question16/SolutionScreenShots/image.png
For the reference of the code