Sezione DSAFacile

Elenco collegato palindromo

Guida dettagliata e implementazione Python per il problema della "Lista collegata palindromo".

Dichiarazione del problema

Facile

Scrivi una funzione is_palindrome_list(arr) che rappresenta una lista concatenata singolarmente come una lista Python arr e restituisce True se è palindromo e False altrimenti.

Vincoli
  • 0 <= len(arr) <= 10^5
  • 0 <= arr[i] <= 9

Esempi

Example 1
Input
arr = [1, 2, 2, 1]
Output
True
Explanation

The list reads the same forward and backward.

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

The list reads [1, 2, 3] forward but [3, 2, 1] backward, which is not equal.

Need a Hint?
Prendi in considerazione l'utilizzo di strutture dati specifiche degli elenchi collegati come set o heap.
Edge Cases to Watch
  • Strutture di input vuote
  • Ingressi a elemento singolo
  • Grandi limiti numerici

Pronto a risolvere?

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

Apri nell'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

Risorse Python consigliate

Espandi le tue conoscenze con tutorial interattivi, foglietti illustrativi e confronti di codici correlati.