This could get controversial, but using built-ins might just be better than building your own clever solution even if the clever solution is of a faster time complexity at face value.
(I did test this on my own computer for lists from size 10 to 10000000, and every time built in sort beat out linear for loop.
In questa pagina del sito puoi guardare il video online Leetcode 169: Majority Element. O(nlogn) is faster than O(n)!? della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Teach Me Python 11 febbraio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 527 volte e gli è piaciuto 15 spettatori. Buona visione!