Pergunta de entrevista da empresa Esri

Find the center of a linked list. Android Application Development specific questions Past project and experience.

Resposta da entrevista

Sigiloso

14 de ago. de 2015

The less interesting option is to iterate through, keep count of the nodes and once you hit the end, find node_count/2 and start over and return data at that element. Other option is use one fast pointer (moves 2 at a time) and one slow pointer (moves one at a time), once the fast pointer hits the end, slow pointer will be exactly half way through so just do slow_ptr->data