Python Nozioni di baseFacile

Trovare elementi non ripetitivi in un array

Guida dettagliata e implementazione Python per il problema "Trovare elementi non ripetitivi in un array".

Dichiarazione del problema

Facile

Scrivi una funzione find_non_repeating(arr) che accetta un elenco di numeri interi arr e restituisce un elenco ordinato di tutti gli elementi che appaiono esattamente una volta nell'array. Se tale elemento non esiste, restituisce una lista vuota.

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

Esempi

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

1 appears once and 4 appears once. 2 and 3 each appear twice.

Example 2
Input
arr = [5, 5, 5]
Output
[]
Explanation

5 appears 3 times. No element appears exactly once.

Example 3
Input
arr = [7, 8, 9]
Output
[7, 8, 9]
Explanation

All elements appear exactly once.

Need a Hint?
Prendi in considerazione l'utilizzo di strutture dati specifiche degli array 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.