Seção DSAFácil

Meio da lista vinculada

Guia detalhado e implementação de Python para o problema 'Middle of Linked List'.

Declaração do problema

Fácil

Escreva uma função middle_node(arr) que represente uma lista vinculada individualmente como uma lista Python arr e retorne a sublista começando no nó do meio. Se houver dois nós intermediários (comprimento par), retorne a sublista começando no segundo nó intermediário.

Restrições
  • 1 <= len(arr) <= 1000
  • -1000 <= arr[i] <= 1000

Exemplos

Example 1
Input
arr = [1, 2, 3, 4, 5]
Output
[3, 4, 5]
Explanation

The middle node is 3, so we return the list from 3 onwards.

Example 2
Input
arr = [1, 2, 3, 4, 5, 6]
Output
[4, 5, 6]
Explanation

The middle nodes are 3 and 4; we return the list from the second middle node 4.

Need a Hint?
Considere usar estruturas de dados específicas de listas vinculadas, como conjuntos ou heaps.
Edge Cases to Watch
  • Estruturas de entrada vazias
  • Entradas de elemento único
  • Grandes limites numéricos

Pronto para resolver?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Abrir no Editor
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Recursos Python recomendados

Expanda seu conhecimento com tutoriais interativos relacionados, folhas de dicas e comparações de código.