• + 0 comments
    function getNode(llist, positionFromTail) {
        // Write your code here
        let index = 0
        let head = llist, prev = null
        
        while (head!==null){
            let temp = head.next
            head.next = prev //inc on linked list
            prev = head
            head = temp 
        }
       
        while(prev!==null){
            if(index == positionFromTail){
                return prev.data
            }
            prev = prev.next
            index++
        }
    
    }