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.
Get Node Value
Get Node Value
Sort by
recency
|
981 Discussions
|
Please Login in order to post a comment
My Java 8 Solution
def getNode(llist, positionFromTail): cur = llist stack = [] while cur : stack.append(cur.data) cur = cur.next for i in range(positionFromTail+1): node_value = stack.pop() return node_value
simple recursive solution in linear time
My Java solution with linear time complexity and constant space complexity: