- Scrubba Wash Bag is it worth it?
- Extracting Internal Visualization Information (PlotTheme, MeshRegion, FaceNormals, etc.)
- What is the best way to get words with a specific number of letters?
- Want to overlay a density plot with a grid of graphics
- NDSolve output where the stepsize becomes zero
- How can I get parallel evaluation of contour plots?
- Who has the winning hand?
- Autosomal genes expression occurs from both alleles simultaneously
- Proportion of amino acids from a random polymer of U and C
- How can I acquire the ability to digest seaweed?
- Why does semen smell like chlorine?
- Where's the actual Palindrome in the season two finale of Fargo?
- Info about Actress Julie Dreyfus
- As the Cold War expanded, what policy did the US implement to “contain” communism?
- What was the name of the man who was beaten by a crowd for tearing up a war poster during WWI?
- Since when (year/decade) is Jesus considered as god?
- When believers die, are they resurrected to heaven with the Lord?
- Bitcoin fake transactions
- Is it true I have to get Baptized to go to the Kingdom of God?
- Can this be a way to reconcile young earth creation with exploding stars 1 million light years away?
Finding the nth to last node in a linked list
I have a linked list with n elements and my goal is to find the 'nth to last element' in the list. I would like to present my approach. Please provide your opinions on whether it is optimal or how may I improve it.
Sample linked list "4->5->6->8->2->9->1"
Suppose the question indicates find 3th to last element in the list.
a)In a single pass, get the length of the linked list
b) Determine which node needs to be traversed upto (len(list)-nth element from last-1)
c) Make (len(list)-nth element from last-1) moves from head to get the element
Run time should be O(n)