Bloomberg L.P. Interview Question: Q1. Singly linked list, know ... | Glassdoor

Interview Question

2013 Financial Software Engineer Interview New York, NY

Q1. Singly linked list, know header node, but do not know

  how many nodes in a list. find out 2nd last node

Interview Answer

3 Answers


using two pointers which points out header node. one pointer move forward to point out 2nd node. then move two pointers forward when one pointer reach out to the last element (null pointer),

Interview Candidate on Apr 23, 2013

Be aware a case of circular loop in the singly linked list. It may not have the 2nd last node.

Anonymous on Sep 6, 2014

Need to check couple cases.
1 - header node pointer is null. No 2nd last node
2 - header node points to itself. No 2nd last node.
3 - At least two distanct nodes & no circular loop. Has a 2nd last node.

Anonymous on Sep 6, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.