- Rain 40 days after Shavous
- Why would it be disrespectful to G-d to say Miryam died “al pi Hashem”?
- Understanding the key concept
- Does 12-54 to 13-56 gauge change require a re-setup?
- SUM function in a calculated column
- Difference Between 2 Dates (number of hours beyond 24 hours)
- mystery no crank, no start
- Car vibrates and has mild drone at 15-45 mph
- EFQ SQL error when using filedCondition on two different taxonomy terms
- Breathing trouble during high intensity
- Was a finger ever grown back with “pixie dust”?
- Did Hillary Clinton say that North Korea requires experienced diplomats rather than tweets?
- What is the industry standard way of calculating and annualizing performance metrics?
- Why the difference between SPY and ^GSPC?
- Feedback on Website Code
- Readable implementation of Trie in Python
- What were the other 8 Nazgul doing while the Witch-King weakened Arnor?
- Actors appearing in both Star Trek and Star Wars?
- How to query inside jsonb column
- Extract max of value in Fact table using date filter
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)