Pergunta de entrevista da empresa Bloomberg

Q1. Singly linked list, know header node, but do not know how many nodes in a list. find out 2nd last node

Respostas da entrevista

Sigiloso

23 de abr. de 2013

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),

Sigiloso

7 de set. de 2014

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

Sigiloso

7 de set. de 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.