Praticar
370 problemas em 27 tópicos. As dicas vêm uma de cada vez, e a solução fica fechada até você pedir.
370 problemas
Tópico · Arrays
0 / 20 concluídos- FácilUma única operação com ações#single-pass#running-minimumtempo O(n)espaço O(1)15 minInput: prices = [8, 3, 6, 1, 9, 4]Output: 8Começar
- FácilRemover duplicados da lista ordenada#two-pointers#in-placetempo O(n)espaço O(1)15 minInput: nums = [1, 1, 2, 3, 3, 3]Output: 3, and nums begins with [1, 2, 3]Começar
- MédioProduto dos outros#prefix-products#two-passtempo O(n)espaço O(n)Entrar25 minInput: nums = [2, 3, 4, 5]Output: [60, 40, 30, 24]Começar
- MédioMaior sequência sem repetição#sliding-window#hash-maptempo O(n)espaço O(n)Entrar25 minInput: items = [1, 2, 3, 2, 4, 5]Output: 4Começar
- DifícilMáximos de cada janela#sliding-window#monotonic-dequetempo O(n)espaço O(n)Entrar40 minInput: nums = [1, 4, 2, 7, 3, 3], k = 3Output: [4, 7, 7, 7]Começar
- FácilValor majoritário#counting#single-passtempo O(n)espaço O(1)15 minInput: nums = [3, 3, 4]Output: 3Começar
- MédioRotacionar k posições à direita#in-place#reversaltempo O(n)espaço O(1)Entrar25 minInput: nums = [1, 2, 3, 4, 5, 6, 7], k = 3Output: [5, 6, 7, 1, 2, 3, 4]Começar
- MédioPercurso em espiral no grid#matrix-traversal#boundary-shrinkingtempo O(rows · cols)espaço O(rows · cols)Entrar25 minInput: [[7]]Output: [7]Começar
- FácilMover o valor-alvo para o fim#two-pointers#write-pointertempo O(n)espaço O(1)15 minInput: nums = [4, 0, 7, 0, 2], v = 0Output: [4, 7, 2, 0, 0]Começar
- MédioSubarray Sums Divisible by K#prefix-sums#hash-map#modular-arithmetictempo O(n)espaço O(min(n, k))Entrar25 minInput: nums = [2, -2, 3, 1, 5], k = 3Output: 6Começar
- DifícilMenor positivo ausente#cyclic-sort#index-as-hometempo O(n)espaço O(1)Entrar35 minInput: nums = [5, 3, -1, 1, 2]Output: 4Começar
- DifícilÁgua retida entre as barras#two-pointers#running-maximumtempo O(n)espaço O(1)Entrar35 minInput: heights = [3, 0, 2, 0, 4, 1, 2]Output: 8Começar
- FácilQuadrados de uma lista ordenada#two-pointers#merge-from-backtempo O(n)espaço O(n)15 minInput: nums = [-5, -2, 1, 3, 4]Output: [1, 4, 9, 16, 25]Começar
- FácilInverter cada bloco de k#in-place-reversal#two-pointerstempo O(n)espaço O(1)15 minInput: nums = [1, 2, 3, 4, 5, 6, 7, 8], k = 3Output: [3, 2, 1, 6, 5, 4, 7, 8]Começar
- FácilÍndice do ponto de equilíbrio#prefix-sums#running-sumtempo O(n)espaço O(1)15 minInput: values = [2, 7, 1, 5, 4]Output: 2Começar
- MédioMaior janela dentro do orçamento#sliding-window#two-pointerstempo O(n)espaço O(1)Entrar25 minInput: costs = [4, 1, 1, 3, 2, 6], budget = 6Output: 3Começar
- FácilMais alto que todos à direita#running-maximum#linear-scantempo O(n)espaço O(n)15 minInput: heights = [16, 17, 4, 3, 5, 2]Output: [17, 5, 2]Começar
- MédioTrês valores que somam zero#two-pointers#sort-first#skip-duplicatestempo O(n²)espaço O(n²)Entrar30 minInput: nums = [-1, 0, 1, 2, -1, -4]Output: [[-1, -1, 2], [-1, 0, 1]]Começar
- MédioPróximo arranjo maior#in-place-reversal#suffix-scantempo O(n)espaço O(1)Entrar25 minInput: nums = [1, 3, 2]Output: [2, 1, 3]Começar
- MédioSubarray de maior produto#kadane#running-min-maxtempo O(n)espaço O(n)Entrar25 minInput: nums = [2, 3, -2, 4]Output: 6Começar
Tópico · Strings
0 / 16 concluídos- FácilMaior prefixo comum#column-scan#string-comparisontempo O(total characters)espaço O(len(words) + len(words[0]))15 minInput: words = ["flower", "flow", "flight"]Output: "fl"Começar
- FácilPrimeiro caractere único#hash-map#two-passtempo O(n)espaço O(k)15 minInput: text = "reference"Output: 2Começar
- MédioCompressão run-length#two-pointers#run-length-encodingtempo O(n)espaço O(n)Entrar25 minInput: text = "aaabccdddd"Output: "a3bc2d4"Começar
- MédioMultiplicar strings de dígitos#digit-arithmetic#carry-propagationtempo O(len(a) · len(b))espaço O(len(a) + len(b))Entrar30 minInput: a = "123", b = "456"Output: "56088"Começar
- DifícilMenor janela de cobertura#sliding-window#hash-maptempo O(len(text) + len(need))espaço O(len(text) + len(need))Entrar45 minInput: text = "ADOBECODEBANC", need = "ABC"Output: "BANC"Começar
- MédioAgrupar anagramas#hash-map#canonical-formtempo O(n · k log k)espaço O(n · k)Entrar20 minInput: words = ["eat", "tea", "tan", "ate", "nat", "bat"]Output: [["ate", "eat", "tea"], ["bat"], ["nat", "tan"]]Começar
- MédioRepeated DNA Sequences#rolling-hash#hash-settempo O(n)espaço O(n)Entrar30 minInput: dna = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"Output: ["AAAAACCCCC", "CCCCCAAAAA"]Começar
- FácilPalíndromo após uma remoção#two-pointers#greedytempo O(n)espaço O(1)20 minInput: s = "racexcar"Output: TrueComeçar
- FácilInverter a ordem das palavras#two-pointers#word-splittempo O(n)espaço O(n)10 minInput: s = " the sky is blue "Output: "blue is sky the"Começar
- DifícilMenor palíndromo adicionando à frente#kmp#palindrometempo O(n)espaço O(n)Entrar40 minInput: s = "abacd"Output: "dcabacd"Começar
- MédioContar substrings palíndromas#expand-around-center#palindrometempo O(n²)espaço O(1)Entrar25 minInput: s = "level"Output: 7Começar
- MédioMenor unidade de repetição#kmp#string-periodtempo O(n)espaço O(n)Entrar25 minInput: s = "xyzxyzxyz"Output: "xyz"Começar
- DifícilQuantas vezes cada prefixo aparece#z-algorithm#suffix-sumstempo O(n)espaço O(n)Entrar40 minInput: s = "abacaba"Output: [4, 2, 2, 1, 1, 1, 1]Começar
- FácilEmpacotar palavras em uma string#length-prefix#string-parsingtempo O(L)espaço O(L)20 minInput: words = ["hi", "#1"]Output: pack -> "2#hi2##1"Começar
- MédioPosições de anagramas em um texto#fixed-sliding-window#frequency-counttempo O(len(text) + len(key))espaço O(len(text))Entrar25 minInput: text = "cbaebabacd", key = "abc"Output: [0, 6]Começar
- FácilNúmero romano para inteiro#string-scan#lookup-tabletempo O(n)espaço O(1)15 minInput: s = "LVIII"Output: 58Começar
Tópico · Busca
0 / 13 concluídos- FácilRaiz quadrada inteira#binary-search#monotonic-predicatetempo O(log n)espaço O(1)20 minInput: n = 8Output: 2Começar
- MédioPico em uma lista irregular#binary-search#slope-followingtempo O(log n)espaço O(1)Entrar30 minInput: nums = [1, 2, 3, 1]Output: 2Começar
- DifícilMediana de duas listas ordenadas#binary-search#partitioningtempo O(log min(m, n))espaço O(1)Entrar50 minInput: a = [1, 3], b = [2]Output: 2.0Começar
- MédioPrimeira e última ocorrência#binary-search#boundary-searchtempo O(log n)espaço O(1)Entrar25 minInput: nums = [5, 7, 7, 8, 8, 10], target = 8Output: (3, 4)Começar
- MédioCapacidade diária mínima#binary-search-on-answer#greedy-checktempo O(n log(sum(weights)))espaço O(1)Entrar30 minInput: weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], days = 5Output: 15Começar
- FácilDistância mínima entre duas palavras#single-pass#linear-scantempo O(n)espaço O(1)15 minInput: words = ["cat", "dog", "fox", "cat", "owl", "dog"], a = "cat", b = "dog"Output: 1Começar
- MédioContar as rotações#binary-search#boundary-searchtempo O(log n)espaço O(1)Entrar20 minInput: nums = [15, 18, 2, 3, 6, 12]Output: 2Começar
- MédioBuscar em lista de tamanho desconhecido#binary-search#exponential-searchtempo O(log p)espaço O(1)Entrar25 minInput: values = [2, 5, 5, 9, 14, 20, 31], target = 9Output: 3Começar
- FácilK-ésimo número que falta na lista#binary-search#countingtempo O(log n)espaço O(1)20 minInput: nums = [2, 3, 4, 7, 11], k = 5Output: 9Começar
- MédioValor em um dado instante#binary-search#upper-bound#versioned-storetempo O(log v)espaço O(number of set calls)Entrar25 minInput: set("port", "80", 10), get("port", 9), get("port", 10)Output: ["", "80"]Começar
- FácilPróxima letra depois do alvo#binary-search#upper-boundtempo O(log n)espaço O(1)15 minInput: letters = ["c", "f", "j"], target = "a"Output: "c"Começar
- MédioAlvo em uma lista ordenada rotacionada#binary-search#rotated-arraytempo O(log n)espaço O(1)Entrar20 minInput: nums = [4, 5, 6, 7, 0, 1, 2], target = 0Output: 4Começar
- DifícilK-ésima menor distância entre pares#binary-search-on-answer#two-pointers#sortingtempo O(n log n + n log(max − min))espaço O(n)Entrar35 minInput: nums = [1, 3, 1], k = 1Output: 0Começar
Tópico · Ordenação
0 / 15 concluídos- FácilPosições fora do lugar#sorting#pairwise-comparisontempo O(n log n)espaço O(n)15 minInput: heights = [1, 1, 4, 2, 1, 3]Output: 3Começar
- MédioOrdenação da bandeira em três vias#dutch-national-flag#in-placetempo O(n)espaço O(1)Entrar30 minInput: values = [2, 0, 2, 1, 1, 0]Output: [0, 0, 1, 1, 2, 2]Começar
- MédioArranjo que forma o maior número#custom-comparator#sortingtempo O(n log n)espaço O(n)Entrar30 minInput: nums = [3, 30, 34, 5, 9]Output: "9534330"Começar
- MédioÍndice h a partir das citações#sorting#countingtempo O(n log n)espaço O(1)Entrar20 minInput: citations = [3, 0, 6, 1, 5]Output: 3Começar
- DifícilMaior diferença com buckets#bucket-sort#pigeonholetempo O(n log n)espaço O(n)Entrar40 minInput: nums = [3, 6, 9, 1]Output: 3Começar
- FácilDeslocamentos do insertion sort#insertion-sort#stable-sorttempo O(n²)espaço O(n)15 minInput: nums = [3, 1, 2]Output: 2Começar
- MédioOrdenar uma lista encadeada#divide-and-conquer#fast-slow-pointerstempo O(n log n)espaço O(log n)Entrar30 minInput: 4 -> 1 -> 3 -> 1 -> 2Output: 1 -> 1 -> 2 -> 3 -> 4Começar
- MédioMenor número de trocas para ordenar#cycle-decomposition#selection-sorttempo O(n log n)espaço O(n)Entrar25 minInput: nums = [4, 3, 1, 2]Output: 3Começar
- MédioK-ésimo menor por particionamento#quickselect#three-way-partitiontempo O(n)espaço O(n)Entrar30 minInput: nums = [7, 2, 9, 4, 4, 1], k = 3Output: 4Começar
- FácilPares abaixo do orçamento#sorting#two-pointerstempo O(n log n)espaço O(n)20 minInput: prices = [4, -2, 0, 3, 1], budget = 3Output: 5Começar
- MédioOrdem após k passadas por dígito#radix-sort#stable-sort#bucket-sorttempo O(k · n)espaço O(n)Entrar25 minInput: nums = [53, 7, 318, 90, 41, 206, 17], k = 1Output: [90, 41, 53, 206, 7, 17, 318]Começar
- DifícilContar pares fora de ordem#merge-sort#divide-and-conquer#inversion-counttempo O(n log n)espaço O(n)Entrar35 minInput: nums = [2, 4, 1, 3, 5]Output: 3Começar
- FácilOrdenar pela ordem de outra lista#counting-sort#custom-ordertempo O(n + k)espaço O(n + k)15 minInput: values = [2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19], order = [2, 1, 4, 3, 9, 6]Output: [2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19]Começar
- MédioViradas de panqueca para ordenar#selection-sort#prefix-reversaltempo O(n²)espaço O(n)Entrar25 minInput: arr = [3, 2, 4, 1]Output: [3, 4, 2, 3, 2]Começar
- FácilPares com a menor diferença#sort-first#adjacent-scantempo O(n log n)espaço O(n)15 minInput: nums = [4, 2, 1, 3]Output: [[1, 2], [2, 3], [3, 4]]Começar
Tópico · Listas encadeadas
0 / 14 concluídos- FácilMesclar cadeias ordenadas#two-pointers#dummy-nodetempo O(n + m)espaço O(1)20 minInput: a = 1 -> 4 -> 6, b = 2 -> 3Output: 1 -> 2 -> 3 -> 4 -> 6Começar
- MédioRemover o n-ésimo a partir do fim#fast-slow-pointers#dummy-nodetempo O(L)espaço O(1)Entrar25 minInput: head = 1 -> 2 -> 3 -> 4 -> 5, n = 2Output: 1 -> 2 -> 3 -> 5Começar
- MédioEntrelaçar as metades da lista#fast-slow-pointers#list-reversaltempo O(n)espaço O(1)Entrar35 minInput: head = 1 -> 2 -> 3 -> 4Output: 1 -> 4 -> 2 -> 3Começar
- FácilRemover nós com um valor#dummy-node#pointer-relinkingtempo O(n)espaço O(1)15 minInput: head = 1 -> 2 -> 6 -> 3 -> 6, target = 6Output: 1 -> 2 -> 3Começar
- MédioSomar duas cadeias de dígitos#dummy-node#carry-propagationtempo O(max(m, n))espaço O(max(m, n))Entrar25 minInput: a = 2 -> 4 -> 3, b = 5 -> 6 -> 4Output: 7 -> 0 -> 8Começar
- MédioParticionar em torno de um valor#dummy-node#list-splittingtempo O(n)espaço O(1)Entrar30 minInput: head = 1 -> 4 -> 3 -> 2 -> 5 -> 2, pivot = 3Output: 1 -> 2 -> 2 -> 4 -> 3 -> 5Começar
- FácilCiclo em uma cadeia#fast-slow-pointers#cycle-detectiontempo O(n)espaço O(1)15 minInput: values = [3, 2, 0, -4], pos = 1Output: TrueComeçar
- FácilHistórico de voltar e avançar#doubly-linked-list#designtempo O(n + Σk)espaço O(n)20 minInput: home = "x", ops = [("back", 2), ("forward", 3)]Output: ['x', 'x']Começar
- MédioOnde o ciclo começa#fast-slow-pointers#cycle-detectiontempo O(n)espaço O(1)Entrar30 minInput: values = [3, 2, 0, -4], pos = 1Output: 2Começar
- MédioClonar uma cadeia com ligações de salto#pointer-relinking#in-placetempo O(n)espaço O(n)Entrar30 minInput: chain = [(3, None), (8, 0), (5, 3), (1, 1)]Output: [(3, None), (8, 0), (5, 3), (1, 1)], built from new nodes onlyComeçar
- FácilCadeia que se lê igual ao contrário#fast-slow-pointers#in-place-reversaltempo O(n)espaço O(1)20 minInput: 1 -> 2 -> 2 -> 1Output: TrueComeçar
- MédioCache LRU#doubly-linked-list#hash-map#sentinel-nodestempo O(1)espaço O(capacity)Entrar35 minComeçar
- DifícilInverter nós em grupos de k#in-place-reversal#dummy-headtempo O(n)espaço O(1)Entrar35 minInput: list = 1 -> 2 -> 3 -> 4 -> 5, k = 2Output: 2 -> 1 -> 4 -> 3 -> 5Começar
- FácilOnde duas cadeias se juntam#two-pointers#list-traversaltempo O(m + n)espaço O(1)15 minInput: a = 2 -> 6 -> 4, b = 1 -> 5, no shared nodesOutput: NoneComeçar
Tópico · Pilhas e filas
0 / 15 concluídos- FácilPilha com mínimo em tempo constante#stack#auxiliary-stacktempo O(1)espaço O(n)20 minComeçar
- MédioDias até esquentar#monotonic-stacktempo O(n)espaço O(n)Entrar30 minInput: temps = [30, 32, 31, 35]Output: [1, 2, 1, 0]Começar
- FácilEliminar pares adjacentes#stack#string-scantempo O(n)espaço O(n)15 minInput: text = "abbaca"Output: "ca"Começar
- MédioDecodificar repetições aninhadas#stack#string-parsingtempo O(output · depth)espaço O(output + depth)Entrar30 minInput: text = "3[a]2[bc]"Output: "aaabcbc"Começar
- DifícilMaior retângulo entre as barras#monotonic-stacktempo O(n)espaço O(n)Entrar45 minInput: heights = [2, 1, 5, 6, 2, 3]Output: 10Começar
- FácilRequisições na última janela#queue#sliding-windowtempo O(n)espaço O(n)15 minInput: times = [0, 400, 900, 1000, 1400], w = 1000Output: [1, 2, 3, 3, 3]Começar
- FácilOperações de fila com duas pilhas#two-stacks#amortizedtempo O(m)espaço O(m)15 minInput: ops = [["push", 7], ["pop"], ["push", 8], ["push", 9], ["peek"]]Output: [7, 8]Começar
- MédioDeque em buffer circular#circular-buffer#designtempo O(1)espaço O(capacity)Entrar25 minComeçar
- FácilAvaliar tokens em notação pós-fixa#stack#expression-evaluationtempo O(n)espaço O(n)15 minInput: tokens = ["2", "1", "+", "3", "*"]Output: 9Começar
- MédioPedras que colidem em linha#stack#pop-while-weakertempo O(n)espaço O(n)Entrar25 minInput: rocks = [5, 10, -5]Output: [5, 10]Começar
- DifícilAvaliar somas com parênteses#stack#expression-parsing#sign-trackingtempo O(n)espaço O(depth)Entrar40 minInput: s = "1 + 1"Output: 2Começar
- FácilBusca do próximo valor maior#monotonic-stack#hash-maptempo O(n + q)espaço O(n + q)15 minInput: nums = [4, 1, 3, 6, 2, 5], queries = [1, 3, 2, 6]Output: [3, 6, 5, -1]Começar
- FácilPreços após o próximo desconto#monotonic-stack#next-smallertempo O(n)espaço O(n)15 minInput: prices = [8, 4, 6, 2, 3]Output: [4, 2, 4, 2, 3]Começar
- MédioSimplificar um caminho Unix#stack#string-parsingtempo O(n)espaço O(n)Entrar20 minInput: path = "/a/./b/../../c/"Output: "/c"Começar
- DifícilMenor sequência com soma de pelo menos K#monotonic-deque#prefix-sumtempo O(n)espaço O(n)Entrar40 minInput: nums = [2, -1, 2], k = 3Output: 3Começar
Tópico · Tabelas hash
0 / 14 concluídos- FácilVerificar valores repetidos#hash-set#single-passtempo O(n)espaço O(n)10 minInput: items = [4, 1, 9, 1]Output: TrueComeçar
- MédioSubarrays com soma K#prefix-sums#hash-maptempo O(n)espaço O(n)Entrar30 minInput: nums = [1, 2, 3, 1], k = 3Output: 2Começar
- MédioMaior sequência consecutiva#hash-set#countingtempo O(n)espaço O(n)Entrar30 minInput: nums = [9, 4, 2, 3, 1, 8]Output: 4Começar
- FácilValores em comum de duas listas#hash-set#membership-testtempo O(n + m)espaço O(m)15 minInput: a = [1, 2, 2, 1], b = [2, 2]Output: [2]Começar
- FácilVerificar renomeação consistente#hash-map#bijectiontempo O(n)espaço O(n)20 minInput: a = "egg", b = "add"Output: TrueComeçar
- MédioQuádruplas com soma zero#hash-map#meet-in-the-middletempo O(n²)espaço O(n²)Entrar30 minInput: a = [1, 2], b = [-2, -1], c = [-1, 2], d = [0, 2]Output: 2Começar
- FácilMenor distância entre repetições#hash-map#single-passtempo O(n)espaço O(n)15 minInput: values = [7, 1, 3, 7, 1, 7]Output: 2Começar
- MédioOnde a sondagem linear termina#open-addressing#union-findtempo O(m + n log m)espaço O(m)Entrar30 minInput: m = 7, keys = [10, 3, 17, 24, 5]Output: [3, 4, 5, 6, 0]Começar
- MédioOrdenar letras por frequência#bucket-sort#countingtempo O(n)espaço O(n)Entrar20 minInput: text = "banana"Output: "aaannb"Começar
- DifícilCache LFU#design#hash-map#frequency-bucketstempo O(1)espaço O(capacity)Entrar45 minComeçar
- MédioMaior trecho balanceado de zeros e uns#prefix-sum#first-seen-indextempo O(n)espaço O(n)Entrar20 minInput: bits = [0, 1, 0]Output: 2Começar
- FácilContar pares com uma diferença dada#hash-map#complement-lookuptempo O(n)espaço O(n)15 minInput: nums = [3, 1, 4, 1, 5], k = 2Output: 2Começar
- FácilBilhete de resgate com letras de revista#frequency-count#hash-maptempo O(n + m)espaço O(1)10 minInput: note = "aab", banner = "baa"Output: TrueComeçar
- MédioAgrupar palavras por deslocamento#canonical-key#hash-map#groupingtempo O(n · L)espaço O(n · L)Entrar20 minInput: words = ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"]Output: [["abc", "bcd", "xyz"], ["acef"], ["az", "ba"], ["a", "z"]]Começar
Tópico · Recursão
0 / 14 concluídos- FácilAchatar uma lista aninhada#recursion#tree-walktempo O(n)espaço O(n)15 minInput: items = [1, [2, [3, 4]], 5]Output: [1, 2, 3, 4, 5]Começar
- MédioMovimentos da torre de discos#recursion#divide-and-conquertempo O(2ⁿ)espaço O(2ⁿ)Entrar20 minInput: n = 1, src = "A", dst = "C", spare = "B"Output: [("A", "C")]Começar
- MédioPotência rápida#recursion#divide-and-conquertempo O(log |exp|)espaço O(log |exp|)Entrar20 minInput: base = 2, exp = 10Output: 1024Começar
- FácilSoma aninhada ponderada por profundidade#recursion#pass-downtempo O(n)espaço O(d)15 minInput: items = [[1, 1], 2, [1, 1]]Output: 10Começar
- MédioSímbolo em uma linha que dobra#recursion#halvingtempo O(n)espaço O(n)Entrar25 minInput: n = 4, k = 5Output: 1Começar
- MédioTodas as formas de pôr parênteses#divide-and-conquer#memoizationtempo O(4ⁿ / √n)espaço O(4ⁿ / √n)Entrar30 minInput: expr = "2-1-1"Output: [0, 2]Começar
- MédioK-ésima menor chave da BST sem recursão#explicit-stack#inordertempo O(h + k)espaço O(h)Entrar25 minInput: same tree; k = 8Output: 14Começar
- FácilDividir por dois ou subtrair um#tail-recursion#bit-countingtempo O(log n)espaço O(1)15 minInput: n = 14Output: 6Começar
- FácilTermo da sequência look-and-say#recursion#run-lengthtempo O(1.31ⁿ)espaço O(1.31ⁿ)15 minInput: n = 4Output: "1211"Começar
- MédioNúmeros de ponta-cabeça com n dígitos#recursion#build-from-inside-outtempo O(n · 5^(n/2))espaço O(n · 5^(n/2))Entrar25 minInput: n = 2Output: ["11", "69", "88", "96"]Começar
- FácilN-ésimo número de Tribonacci#recurrence#rolling-statetempo O(n)espaço O(1)10 minInput: n = 4Output: 4Começar
- DifícilVerificar string embaralhada#recursion#memoization#divide-and-conquertempo O(n⁴ log n)espaço O(n³)Entrar40 minInput: s1 = "great", s2 = "rgeat"Output: TrueComeçar
- MédioÚltimo amigo que sobra na roda#recursion#josephus#recurrencetempo O(n)espaço O(1)Entrar25 minInput: n = 5, k = 2Output: 3Começar
- FácilPalíndromo ignorando a pontuação#tail-recursion#two-pointerstempo O(n)espaço O(1)15 minInput: s = "A man, a plan, a canal: Panama"Output: TrueComeçar
Tópico · Backtracking
0 / 14 concluídos- MédioPalavras do teclado do telefone#backtracking#decision-treetempo O(n · 3ⁿ)espaço O(n · 3ⁿ)Entrar20 minInput: digits = "23"Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]Começar
- MédioCombinações com soma alvo#backtracking#pruningtempo O(n^(target / min))espaço O(n^(target / min))Entrar25 minInput: nums = [2, 3, 6, 7], target = 7Output: [[2, 2, 3], [7]]Começar
- MédioDividir em palíndromos#backtracking#pruningtempo O(n · 2ⁿ)espaço O(n · 2ⁿ)Entrar25 minInput: s = "aab"Output: [["a", "a", "b"], ["aa", "b"]]Começar
- FácilVariações de maiúsculas e minúsculas#backtracking#include-excludetempo O(n · 2^L)espaço O(n · 2^L)15 minInput: s = "a1b"Output: ["a1b", "a1B", "A1b", "A1B"]Começar
- MédioStrings de parênteses balanceados#backtracking#pruningtempo O(4ⁿ / √n)espaço O(4ⁿ / √n)Entrar25 minInput: n = 3Output: ["((()))", "(()())", "(())()", "()(())", "()()()"]Começar
- DifícilContar posicionamentos de rainhas#backtracking#constraint-setstempo O(n!)espaço O(n)Entrar40 minInput: n = 4Output: 2Começar
- MédioArranjos distintos#backtracking#pruning#sortingtempo O(n · n!)espaço O(n · n!)Entrar30 minInput: vals = [1, 2, 1]Output: [[1, 1, 2], [1, 2, 1], [2, 1, 1]]Começar
- MédioRecolocar os pontos nos endereços#backtracking#pruningtempo O(1)espaço O(1)Entrar30 minInput: s = "25525511135"Output: ["255.255.11.135", "255.255.111.35"]Começar
- DifícilPreencher um grid de sudoku#backtracking#constraint-setsEntrar45 minInput: the first row is "11......." and the rest are emptyOutput: FalseComeçar
- DifícilPalitos de fósforo formando um quadrado#backtracking#pruning#k-way-partitiontempo O(4ⁿ)espaço O(n)Entrar40 minInput: sticks = [1, 1, 2, 2, 2]Output: TrueComeçar
- FácilStrings binárias sem 1s adjacentes#backtracking#pruningtempo O(n · 1.62ⁿ)espaço O(n · 1.62ⁿ)15 minInput: n = 3Output: ["000", "001", "010", "100", "101"]Começar
- MédioTraçar uma palavra num grid de letras#backtracking#grid-dfs#pruningtempo O(rows · cols · 3^L)espaço O(rows · cols + L)Entrar25 minInput: board = ["ABCE", "SFCS", "ADEE"], word = "ABCCED"Output: TrueComeçar
- FácilEscolher K dos N primeiros números#backtracking#combinations#pruningtempo O(k · C(n, k))espaço O(k · C(n, k))15 minInput: n = 4, k = 2Output: [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]Começar
- FácilArranjos de dígitos até um limite#backtracking#permutations#pruningtempo O(n · n!)espaço O(n!)15 minInput: digits = [3, 1, 2], limit = 300Output: [123, 132, 213, 231]Começar
Tópico · Algoritmos gulosos
0 / 13 concluídos- MédioMenos remoções para evitar conflitos#greedy#interval-scheduling#sortingtempo O(n log n)espaço O(1)Entrar20 minInput: spans = [(1, 2), (2, 3), (3, 4), (1, 3)]Output: 1Começar
- MédioMenos saltos até o fim#greedy#reach-frontiertempo O(n)espaço O(1)Entrar20 minInput: nums = [2, 3, 1, 1, 4]Output: 2Começar
- MédioDividir a string em blocos#greedy#last-occurrencetempo O(n)espaço O(1)Entrar20 minInput: s = "abacdc"Output: [3, 3]Começar
- FácilDistribuir biscoitos#greedy#sorting#two-pointerstempo O(n log n + m log m)espaço O(n + m)15 minInput: wants = [1, 2, 3], sizes = [1, 1]Output: 1Começar
- MédioRota circular de combustível#greedy#running-sumtempo O(n)espaço O(1)Entrar25 minInput: fuel = [1, 2, 3, 4, 5], cost = [3, 4, 5, 1, 2]Output: 3Começar
- DifícilDivisão justa de doces#greedy#two-passtempo O(n)espaço O(n)Entrar40 minInput: scores = [1, 0, 2]Output: 5Começar
- MédioUnir cordas pelo menor custo#greedy#min-heaptempo O(n log n)espaço O(n)Entrar25 minInput: lengths = [4, 3, 2, 6]Output: 29Começar
- FácilDividir candidatos entre duas cidades#greedy#sort-by-differencetempo O(n log n)espaço O(n)20 minInput: costs = [[10, 20], [30, 200], [400, 50], [30, 20]]Output: 110Começar
- MédioMáximo de eventos para participar#greedy#min-heap#earliest-deadlinetempo O(n log n)espaço O(n)Entrar30 minInput: events = [[1, 2], [2, 3], [3, 4], [1, 2]]Output: 4Começar
- MédioMenos clipes para cobrir a transmissão#greedy#reach-frontier#interval-covertempo O(n + T)espaço O(T)Entrar25 minInput: clips = [[0, 2], [4, 6], [8, 10], [1, 9], [1, 5], [5, 9]], T = 10Output: 3Começar
- FácilMenor início para um percurso positivo#running-sum#prefix-minimumtempo O(n)espaço O(1)10 minInput: nums = [-3, 2, -3, 4, 2]Output: 5Começar
- MédioMaior cadeia de pares#greedy#sort-by-end#interval-schedulingtempo O(n log n)espaço O(n)Entrar20 minInput: pairs = [[1, 2], [2, 3], [3, 4]]Output: 2Começar
- FácilDá para chegar ao último índice#greedy#farthest-reachtempo O(n)espaço O(1)15 minInput: jumps = [2, 3, 1, 1, 4]Output: TrueComeçar
Tópico · Árvores e BST
0 / 17 concluídos- FácilContagem do nível mais profundo#dfs#recursiontempo O(n)espaço O(h)15 minInput: tree = 3 with children 9 and 20, where 20 has children 15 and 7Output: 3Começar
- MédioPercurso em zigue-zague por nível#bfs#level-ordertempo O(n)espaço O(n)Entrar30 minInput: tree = 3 with children 9 and 20, where 20 has children 15 and 7Output: [[3], [20, 9], [15, 7]]Começar
- MédioVista pela direita#bfs#level-ordertempo O(n)espaço O(n)Entrar25 minInput: tree = 1, left child 2 with right child 5, right child 3 with right child 4Output: [1, 3, 4]Começar
- FácilVerificação de simetria espelhada#recursion#paired-traversaltempo O(n)espaço O(h)20 minInput: tree = 1, left 2 with children 3 and 4, right 2 with children 4 and 3Output: TrueComeçar
- FácilSoma alvo da raiz até a folha#dfs#recursiontempo O(n)espaço O(h)20 minInput: tree = 1 with a single left child 2; target = 1Output: FalseComeçar
- MédioCaminho mais longo entre dois nós#dfs#post-ordertempo O(n)espaço O(h)Entrar30 minInput: tree = 1 with left child 2 having children 4 and 5, and right child 3Output: 3Começar
- DifícilReconstruir a partir de dois percursos#divide-and-conquer#hash-map#recursiontempo O(n)espaço O(n)Entrar45 minInput: before = [3, 9, 20, 15, 7], middle = [9, 3, 15, 20, 7]Output: 3 with left child 9 and right child 20, whose children are 15 and 7Começar
- FácilChave mais próxima em uma BST#bst#search-pathtempo O(h)espaço O(1)15 minInput: same tree; target = 12.2Output: 14Começar
- MédioDistância entre duas chaves de uma BST#bst#lowest-common-ancestortempo O(h)espaço O(1)Entrar25 minInput: same tree; a = 6, b = 7Output: 1Começar
- FácilProfundidade da folha mais rasa#bfs#level-ordertempo O(n)espaço O(w)15 minInput: tree = 6, left 2 (whose left is 1, whose left is 0), right 9Output: 2Começar
- MédioAchatar uma árvore em uma cadeia#preorder#explicit-stacktempo O(n)espaço O(h)Entrar25 minInput: tree = 7, left 3 (children 1 and 5), right 9 (left child 8)Output: chain 7 -> 3 -> 1 -> 5 -> 9 -> 8Começar
- MédioVista de cima de uma árvore#bfs#column-indextempo O(n)espaço O(n)Entrar25 minInput: tree = 8, left 4, whose left is 2Output: [2, 4, 8]Começar
- MédioMaior BST dentro de uma árvore#post-order#bsttempo O(n)espaço O(h)Entrar30 minInput: tree = 5, left 3, right 8 (children 7 and 9)Output: 5Começar
- MédioSerialização compacta de BST#preorder#monotonic-stack#bsttempo O(n)espaço O(n)Entrar30 minInput: tree = 8, left 3 (children 1 and 6), right 10 (right child 14)Output: encode -> "8 3 1 6 10 14"Começar
- FácilEspelhar uma árvore binária#recursion#tree-traversaltempo O(n)espaço O(h)10 minInput: tree = 4, left 2 (children 1 and 3), right 7 (children 6 and 9)Output: [4, 7, 2, 9, 6, 3, 1]Começar
- DifícilMelhor soma de caminho entre nós#post-order#tree-dp#global-besttempo O(n)espaço O(h)Entrar35 minInput: tree = -10, left 9, right 20 (children 15 and 7)Output: 42Começar
- FácilVerificar se a árvore é balanceada#post-order#early-exittempo O(n)espaço O(h)15 minInput: tree = 3, left 9, right 20 (children 15 and 7)Output: TrueComeçar
Tópico · Tries
0 / 12 concluídos- MédioBusca de palavras com curinga#trie#backtrackingtempo O(26ᵈ · m)espaço O(total characters)Entrar30 minInput: words = ["bad", "dad", "mad"], query = ".ad"Output: TrueComeçar
- MédioSubstituir palavras pelas raízes#trie#prefix-matchtempo O(R + S)espaço O(R + S)Entrar25 minInput: roots = ["cat", "bat", "rat"], sentence = "the cattle was rattled by the battery"Output: "the cat was rat by the bat"Começar
- DifícilPar com XOR máximo#bit-trie#greedytempo O(n · b)espaço O(n · b)Entrar40 minInput: nums = [3, 10, 5, 25, 2, 8]Output: 28Começar
- FácilOperações de uma trie#trie#designtempo O(L)espaço O(total characters)20 minInput: insert("apple"), has_word("apple"), has_word("app"), has_prefix("app")Output: True, False, TrueComeçar
- MédioAutocompletar com três sugestões#trie#prefix-matchtempo O(n log n + total characters)espaço O(total characters)Entrar30 minInput: products = ["mobile", "mouse", "moneypot", "monitor", "mousepad"], word = "mouse"Output: [["mobile", "moneypot", "monitor"],Começar
- DifícilPalavras do dicionário em um grid#trie#backtracking#grid-dfstempo O(cells · 4 · 3^(L−1))espaço O(total word characters)Entrar45 minInput: grid = [["a"]], words = ["a", "aa"]Output: ["a"]Começar
- MédioMaior palavra montada letra a letra#trie#dfstempo O(total characters)espaço O(total characters)Entrar25 minInput: words = ["w", "wo", "wor", "worl", "world"]Output: "world"Começar
- FácilSoma de valores por prefixo#trie#designtempo O(L)espaço O(total characters)20 minInput: put("apple", 3), total("ap"), put("app", 2), total("ap"), total("apple")Output: 3, 5, 3Começar
- DifícilFins de palavra em um stream de letras#trie#reversed-trie#streamtempo O(L)espaço O(total characters + L)Entrar40 minInput: words = ["cd", "f", "kl"], stream = "abcdefghijkl"Output: [F, F, F, T, F, T, F, F, F, F, F, T]Começar
- MédioMenores prefixos únicos#trie#prefix-counttempo O(L)espaço O(L)Entrar25 minInput: words = ["zebra", "dog", "duck", "dove"]Output: ["z", "dog", "du", "dov"]Começar
- FácilAchar palavras do dicionário em um texto#trie#prefix-pruningtempo O(n · L + W)espaço O(W + n · L)15 minInput: text = "bytesofcode", words = ["byte", "bytes", "code", "of", "so"]Output: [[0, 3], [0, 4], [4, 5], [5, 6], [7, 10]]Começar
- MédioCodificação mais curta de palavras#trie#suffix-sharingtempo O(W)espaço O(W)Entrar25 minInput: words = ["time", "me", "bell"]Output: 10Começar
Tópico · Heaps
0 / 14 concluídos- MédioK-ésimo maior valor#min-heap#top-ktempo O(n log k)espaço O(k)Entrar25 minInput: nums = [3, 2, 1, 5, 6, 4], k = 2Output: 5Começar
- FácilEsmagar as pedras mais pesadas#max-heap#simulationtempo O(n log n)espaço O(n)20 minInput: stones = [2, 7, 4, 1, 8, 1]Output: 1Começar
- MédioPontos mais próximos da origem#max-heap#top-ktempo O(n log k)espaço O(k)Entrar30 minInput: points = [[3, 3], [5, -1], [-2, 4]], k = 2Output: [(3, 3), (-2, 4)]Começar
- DifícilMediana contínua de um stream#two-heaps#streamingtempo O(n log n)espaço O(n)Entrar45 minInput: stream = [5, 15, 1, 3]Output: [5.0, 10.0, 5.0, 4.0]Começar
- MédioAgendador de tarefas com cooldown#heap#greedytempo O(n log d + n · gap)espaço O(d)Entrar35 minInput: tasks = ["a", "a", "a", "b", "b", "b"], gap = 2Output: 8Começar
- MédioReorganizar string sem vizinhos iguais#heap#greedytempo O(n log d)espaço O(n)Entrar30 minInput: s = "aab"Output: "aba"Começar
- FácilVerificar se o array é um min-heap#heap#array-as-treetempo O(n)espaço O(1)15 minInput: values = [1, 3, 2, 7, 4]Output: TrueComeçar
- MédioOrdenar uma lista quase ordenada#min-heap#k-sortedtempo O(n log k)espaço O(n)Entrar25 minInput: nums = [3, 1, 2, 6, 4, 5], k = 2Output: [1, 2, 3, 4, 5, 6]Começar
- MédioAté onde vão tijolos e escadas#min-heap#greedytempo O(n log ladders)espaço O(ladders)Entrar30 minInput: heights = [4, 2, 7, 6, 9, 14, 12], bricks = 5, ladders = 1Output: 4Começar
- MédioProcessar tarefas em uma única CPU#min-heap#event-simulationtempo O(n log n)espaço O(n)Entrar30 minInput: tasks = [[1, 2], [2, 4], [3, 2], [4, 1]]Output: [0, 2, 3, 1]Começar
- FácilOs K esquadrões mais fracos#top-k#max-heaptempo O(m · n + m log k)espaço O(k)20 minInput: roster = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]], k = 3Output: [2, 0, 3]Começar
- FácilOs K valores mais próximos do alvo#top-k#max-heaptempo O(n log k)espaço O(k)15 minInput: nums = [9, 2, 14, 5, 7, 11], target = 8, k = 3Output: [5, 7, 9]Começar
- FácilHeapify in-place de uma lista#heapify#sift-downtempo O(n)espaço O(1)15 minInput: nums = [5, 3, 8, 1, 2]Output: [1, 2, 8, 3, 5]Começar
- MédioEspalhar letras com distância mínima K#max-heap#greedy#cooldown-queuetempo O(n)espaço O(n)Entrar30 minInput: s = "aabbcc", k = 3Output: "abcabc"Começar
Tópico · Dois heaps e k-way merge
0 / 14 concluídos- MédioK-ésimo menor valor da matriz#k-way-merge#heaptempo O(n + k log n)espaço O(n)Entrar30 minInput: matrix = [[1, 5, 9], [10, 11, 13], [12, 13, 15]], k = 8Output: 13Começar
- DifícilMenor intervalo que cobre K listas#k-way-merge#sliding-windowtempo O(n log k)espaço O(k)Entrar45 minInput: lists = [[4, 10, 15, 24, 26], [0, 9, 12, 20], [5, 18, 22, 30]]Output: [20, 24]Começar
- DifícilEscolher projetos com o capital#two-heaps#greedytempo O(n log n)espaço O(n)Entrar40 minInput: projects = [(0, 1), (1, 2), (2, 3)], capital = 0, rounds = 2Output: 3Começar
- FácilMesclar K sequências ordenadas#k-way-merge#min-heaptempo O(n log k)espaço O(n)20 minInput: lists = [[1, 4, 5], [1, 3, 4], [2, 6]]Output: [1, 1, 2, 3, 4, 4, 5, 6]Começar
- MédioAs K menores somas de pares#k-way-merge#min-heaptempo O(k log k)espaço O(k)Entrar30 minInput: a = [1, 7, 11], b = [2, 4, 6], k = 3Output: [[1, 2], [1, 4], [1, 6]]Começar
- DifícilMediana da janela deslizante#two-heaps#lazy-deletion#sliding-windowtempo O(n log n)espaço O(n)Entrar45 minInput: nums = [1, 3, -1, -3, 5, 3, 6, 7], k = 3Output: [1.0, -1.0, -1.0, 3.0, 5.0, 6.0]Começar
- MédioOs K valores mais frequentes#top-k#min-heap#hash-maptempo O(n + d log k)espaço O(d)Entrar25 minInput: values = [4, 1, 4, 2, 1, 4, 3], k = 2Output: [4, 1]Começar
- MédioPróximo intervalo à direita#two-heaps#max-heaptempo O(n log n)espaço O(n)Entrar30 minInput: spans = [[3, 4], [2, 3], [1, 2]]Output: [-1, 0, 1]Começar
- MédioKth Smallest Prime Fraction#k-way-merge#min-heaptempo O((n + k) log n)espaço O(n)Entrar30 minInput: values = [1, 2, 3, 5], k = 3Output: [2, 5]Começar
- FácilPontuação do meio após cada entrada#two-heaps#streamingtempo O(n log n)espaço O(n)20 minInput: scores = [5, 15, 1, 3]Output: [5, 5, 5, 3]Começar
- FácilSpread bid-ask após cada oferta#two-heaps#max-heap#min-heaptempo O(n log n)espaço O(n)15 minInput: quotes = [("buy", 100), ("sell", 105), ("buy", 102), ("sell", 104), ("buy", 99)]Output: [None, 5, 3, 2, 2]Começar
- MédioAs K palavras mais frequentes#top-k#min-heap#hash-maptempo O(n + m log k)espaço O(m)Entrar20 minInput: words = ["red", "blue", "red", "green", "blue", "red"], k = 2Output: ["red", "blue"]Começar
- FácilK-ésima maior pontuação em um stream#min-heap#top-k#data-streamtempo O(n log k)espaço O(k)15 minInput: k = 3, scores = [4, 5, 8, 2], then add 3, 5, 10, 9, 4Output: [4, 5, 5, 8, 8]Começar
- DifícilNivelar cada janela pelo menor custo#two-heaps#sliding-window#lazy-deletiontempo O(n log n)espaço O(n)Entrar40 minInput: nums = [1, 3, 2, 8, 5, 5], k = 3Output: [2, 6, 6, 3]Começar
Tópico · Grafos
0 / 21 concluídos- MédioContar ilhas no grid#dfs#flood-fill#grid-traversaltempo O(rows · cols)espaço O(rows · cols)Entrar30 minInput: [[1]]Output: 1Começar
- MédioViabilidade da ordem das disciplinas#topological-sort#cycle-detectiontempo O(n + p)espaço O(n + p)Entrar35 minInput: n = 3, pairs = [[1, 0], [2, 1]]Output: TrueComeçar
- DifícilPassos na escada de palavras#bfs#shortest-pathtempo O(N · L² · 26)espaço O(N · L)Entrar45 minInput: start = hit, target = cog, words = [hot, dot, dog, lot, log, cog]Output: 5Começar
- FácilO juiz de confiança da cidade#degree-counting#directed-graphtempo O(n + p)espaço O(n)15 minInput: n = 2, trust = [[1, 2]]Output: 2Começar
- MédioCópia profunda de um grafo#dfs#hash-maptempo O(V + E)espaço O(V)Entrar30 minInput: a square: 1 - 2 - 3 - 4 - 1Output: a new square with the same four labels and the same four linksComeçar
- MédioMinutos até tudo apodrecer#bfs#multi-source#grid-traversaltempo O(rows · cols)espaço O(rows · cols)Entrar30 minInput: [[0, 2]]Output: 0Começar
- MédioVerificar divisão em duas cores#bfs#graph-colouringtempo O(V + E)espaço O(V)Entrar30 minInput: adj = [[1, 3], [0, 2], [1, 3], [0, 2]]Output: TrueComeçar
- MédioTempo de propagação do sinal#dijkstra#shortest-path#min-heaptempo O((n + m) log m)espaço O(n + m)Entrar30 minInput: n = 3, links = [(0, 1, 4)], source = 0Output: -1Começar
- MédioViagem mais barata com limite de escalas#bellman-ford#shortest-pathtempo O(k · (n + m))espaço O(n)Entrar35 minInput: n = 3, flights = [(0, 1, 5)], src = 0, dst = 2, k = 1Output: -1Começar
- DifícilGrupos de alcance mútuo#strongly-connected-components#dfstempo O(n log n + m)espaço O(n + m)Entrar45 minInput: n = 5, edges = [(0, 1), (1, 2), (2, 0), (2, 3), (3, 4)]Output: [[0, 1, 2], [3], [4]]Começar
- DifícilTravessia com a maré subindo#union-find#minimum-spanning-tree#sortingtempo O(rc log rc)espaço O(rc)Entrar45 minInput: heights = [[7]]Output: 7Começar
- MédioNós livres de ciclos#dfs#graph-colouring#cycle-detectiontempo O(n + e)espaço O(n)Entrar30 minInput: graph = [[1, 2], [2], [3], [], [5], [4], [3, 4]]Output: [0, 1, 2, 3]Começar
- FácilPares que se seguem#adjacency-set#directed-graphtempo O(n + m)espaço O(n + m)15 minInput: n = 4, follows = [[0, 1], [1, 0], [1, 2], [2, 3], [3, 2], [0, 2]]Output: 2Começar
- DifícilÁgua para todas as casas#prim#virtual-nodetempo O((n + m) log(n + m))espaço O(n + m)Entrar40 minInput: wells = [3, 4, 2], pipes = [[1, 2, 1], [2, 3, 5]]Output: 6Começar
- DifícilMínimo de estradas para ligar as cidades#strongly-connected-components#directed-graphtempo O(n + r)espaço O(n + r)Entrar45 minInput: n = 5, roads = [(0, 1), (1, 2), (2, 0), (3, 2), (3, 4)]Output: 2Começar
- FácilOrdenar as etapas do build#topological-sort#indegreetempo O(n + m)espaço O(n + m)20 minInput: n = 4, deps = [[0, 1], [0, 2], [1, 3], [2, 3]]Output: [0, 1, 2, 3]Começar
- FácilDeadlock em um grafo de espera#cycle-detection#graph-colouring#topological-sorttempo O(n + m)espaço O(n + m)20 minInput: n = 4, waits = [[0, 1], [1, 2], [2, 0], [3, 0]]Output: TrueComeçar
- FácilRota mais barata entre duas paradas#dijkstra#min-heaptempo O((n + m) log n)espaço O(n + m)20 minInput: n = 5, roads = [[0, 1, 4], [0, 2, 1], [2, 1, 2], [1, 3, 1], [2, 3, 5], [3, 4, 3]], src = 0, dst = 4Output: 7Começar
- FácilMenores caminhos com reembolsos#bellman-ford#negative-edgestempo O(n · m)espaço O(n)20 minInput: n = 4, roads = [[0, 1, 4], [0, 2, 5], [2, 1, -3], [1, 3, 2]], src = 0Output: [0, 2, 5, 4]Começar
- DifícilOrdem do alfabeto alienígena#topological-sort#graph-from-constraintstempo O(L)espaço O(len(words))Entrar40 minInput: words = ["wrt", "wrf", "er", "ett", "rftt"]Output: "wertf"Começar
- FácilAbrir todas as salas trancadas#dfs#reachabilitytempo O(n + k)espaço O(n)15 minInput: rooms = [[1], [2], [3], []]Output: TrueComeçar
Tópico · Matrizes e grids
0 / 14 concluídos- FácilPerímetro de uma ilha#grid-scan#neighbour-checktempo O(rows · cols)espaço O(1)20 minInput: grid = [[1]]Output: 4Começar
- MédioZerar linhas e colunas#grid-marking#in-placetempo O(rows · cols)espaço O(rows + cols)Entrar25 minComeçar
- MédioBusca em um grid ordenado#staircase-walk#grid-searchtempo O(rows + cols)espaço O(1)Entrar25 minInput: same grid, target = 10Output: NoneComeçar
- FácilRepintar uma região conectada#flood-fill#dfstempo O(rows · cols)espaço O(rows · cols)15 minInput: grid = [[5]], row = 0, col = 0, colour = 3Output: [[3]]Começar
- MédioRotacionar um grid quadrado#in-place#transpose-reversetempo O(n²)espaço O(1)Entrar20 minInput: grid = [[7]]Output: [[7]]Começar
- DifícilCaminho de subida mais longo#grid-dfs#memoizationtempo O(rows · cols)espaço O(rows · cols)Entrar40 minComeçar
- MédioIlhas longe da borda#flood-fill#grid-traversaltempo O(rows · cols)espaço O(rows · cols)Entrar30 minInput: grid = [[1]]Output: 0Começar
- MédioMenor caminho livre no grid#bfs#grid-traversal#shortest-pathtempo O(rows · cols)espaço O(rows · cols)Entrar25 minInput: grid = [[0]]Output: 0Começar
- DifícilMaior retângulo só de uns#monotonic-stack#grid-scantempo O(rows · cols)espaço O(cols)Entrar45 minInput: grid = [[1, 1, 0, 1, 1, 1]]Output: 3Começar
- FácilMesmo valor em cada diagonal#matrix-indexing#diagonalstempo O(rows · cols)espaço O(1)15 minInput: grid = [[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]]Output: TrueComeçar
- MédioPróxima geração de células#eight-neighbours#in-place-encodingtempo O(rows · cols)espaço O(1)Entrar25 minInput: board = [[0, 1, 0], [0, 0, 1], [1, 1, 1], [0, 0, 0]]Output: [[0, 0, 0], [1, 0, 1], [0, 1, 1], [0, 1, 0]]Começar
- MédioCélulas que escoam para as duas costas#reverse-flood-fill#multi-source-searchtempo O(rows · cols · log(rows · cols))espaço O(rows · cols)Entrar30 minInput: heights = [[1, 2], [4, 3]]Output: [[0, 1], [1, 0], [1, 1]]Começar
- FácilÁrea da maior ilha#flood-fill#dfs#grid-traversaltempo O(rows · cols)espaço O(rows · cols)15 minInput: grid = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 1], [0, 0, 1, 0]]Output: 4Começar
- FácilPreencher um grid em ordem espiral#matrix-traversal#direction-turningtempo O(rows · cols)espaço O(rows · cols)15 minInput: rows = 3, cols = 3Output: [[1, 2, 3], [8, 9, 4], [7, 6, 5]]Começar
Tópico · Union-Find
0 / 12 concluídos- MédioContar províncias#union-find#connected-componentstempo O(n² · α(n))espaço O(n)Entrar25 minInput: matrix = [[1, 1, 0], [1, 1, 0], [0, 0, 1]]Output: 2Começar
- MédioRedundant Connection#union-find#cycle-detectiontempo O(n · α(n))espaço O(n)Entrar25 minInput: edges = [[1, 2], [1, 3], [2, 3]]Output: [2, 3]Começar
- DifícilMesclar contas por e-mail#union-find#hash-maptempo O(E log E)espaço O(E)Entrar45 minInput: [["Jo", "a@x", "b@x"], ["Jo", "b@x", "c@x"], ["Kim", "d@x"]]Output: [["Jo", "a@x", "b@x", "c@x"], ["Kim", "d@x"]]Começar
- FácilVerificar se um par é alcançável#union-find#connectivitytempo O((n + m) · α(n))espaço O(n)15 minInput: n = 3, links = [[0, 1], [1, 2], [2, 0]], source = 0, target = 2Output: TrueComeçar
- MédioIgualdades consistentes#union-find#two-phasetempo O(n)espaço O(1)Entrar25 minInput: rules = ["a==b", "b!=a"]Output: FalseComeçar
- MédioPedras na mesma linha#union-find#connected-componentstempo O(n · α(n))espaço O(n)Entrar30 minInput: stones = [[0, 0], [0, 1], [1, 0], [1, 2], [2, 1], [2, 2]]Output: 5Começar
- MédioPrimeiro momento com tudo conectado#union-find#sort-by-timetempo O(m log m + m · α(n))espaço O(n + m)Entrar25 minInput: n = 5, logs = [[20, 0, 1], [3, 3, 4], [5, 1, 2], [9, 2, 3], [12, 0, 3]]Output: 12Começar
- MédioMenor string equivalente#union-find#stringstempo O(n + m)espaço O(m)Entrar25 minInput: a = "parker", b = "morris", text = "parser"Output: "makkek"Começar
- DifícilEstradas de sobra para dois viajantes#union-find#greedytempo O(m · α(n))espaço O(n)Entrar45 minInput: n = 4, roads = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4]]Output: 2Começar
- DifícilMaior grupo por fator comum#union-find#prime-factorstempo O(n · √max(nums))espaço O(n)Entrar45 minInput: nums = [4, 6, 15, 35]Output: 4Começar
- FácilAs arestas formam uma única árvore#union-find#cycle-detectiontempo O(n · α(n))espaço O(n)15 minInput: n = 5, edges = [[0, 1], [0, 2], [0, 3], [1, 4]]Output: TrueComeçar
- MédioIlhas após cada terra adicionada#union-find#online-connectivity#gridtempo O(k · α(m · n))espaço O(k)Entrar30 minInput: m = 3, n = 3, positions = [[0, 0], [0, 1], [1, 2], [2, 1]]Output: [1, 1, 2, 3]Começar
Tópico · Intervalos
0 / 13 concluídos- MédioRemoções para evitar sobreposições#intervals#greedytempo O(n log n)espaço O(n)Entrar25 minInput: intervals = [[1, 2], [2, 3], [3, 4], [1, 3]]Output: 1Começar
- DifícilEmployee Free Time#intervals#mergetempo O(n log n)espaço O(n)Entrar40 minInput: schedules = [[[1, 2], [5, 6]], [[1, 3]], [[4, 10]]]Output: [[3, 4]]Começar
- MédioCapacidade da carona compartilhada#intervals#sweep-linetempo O(n log n)espaço O(n)Entrar25 minInput: trips = [(2, 1, 5), (3, 3, 7)], capacity = 4Output: FalseComeçar
- FácilComparecer a todas as reuniões#intervals#sortingtempo O(n log n)espaço O(n)15 minInput: meetings = [[0, 30], [5, 10], [15, 20]]Output: FalseComeçar
- FácilCondensar valores em faixas#intervals#single-passtempo O(n)espaço O(n)15 minInput: nums = [0, 1, 2, 4, 5, 7]Output: ["0->2", "4->5", "7"]Começar
- MédioMesclar intervalos sobrepostos#intervals#sorting#mergetempo O(n log n)espaço O(n)Entrar20 minInput: spans = [[1, 3], [8, 10], [2, 6], [15, 18]]Output: [[1, 6], [8, 10], [15, 18]]Começar
- MédioInserir e mesclar um intervalo#intervals#mergetempo O(n)espaço O(n)Entrar25 minInput: spans = [[1, 2], [4, 6], [9, 10]], new = [5, 9]Output: [[1, 2], [4, 10]]Começar
- MédioInterseção de duas listas de intervalos#intervals#two-pointerstempo O(m + n)espaço O(m + n)Entrar25 minInput: a = [[0, 2], [5, 10], [13, 23], [24, 25]], b = [[1, 5], [8, 12], [15, 24], [25, 26]]Output: [[1, 2], [5, 5], [8, 10], [15, 23], [24, 24], [25, 25]]Começar
- MédioRemover intervalos cobertos por outros#intervals#sort-by-starttempo O(n log n)espaço O(n)Entrar20 minInput: spans = [[1, 4], [3, 6], [2, 8]]Output: 2Começar
- MédioAgenda sem reservas sobrepostas#sorted-intervals#bisect-insert#half-open-intervalstempo O(n)espaço O(n)Entrar25 minInput: book(10, 20), book(15, 25), book(20, 30)Output: [True, False, True]Começar
- MédioMenos tiros para estourar os balões#intervals#greedy#sort-by-endtempo O(n log n)espaço O(n)Entrar25 minInput: balloons = [[10, 16], [2, 8], [1, 6], [7, 12]]Output: 2Começar
- MédioSalas para todas as reuniões#min-heap#sweep-line#sortingtempo O(n log n)espaço O(n)Entrar20 minInput: meetings = [(0, 30), (5, 10), (15, 20)]Output: 2Começar
- FácilCortar um intervalo da lista ordenada#interval-overlap#single-passtempo O(n)espaço O(n)15 minInput: spans = [[0, 2], [3, 4], [5, 7]], cut = [1, 6]Output: [[0, 1], [6, 7]]Começar
Tópico · Manipulação de bits
0 / 14 concluídos- FácilInverter a ordem dos bits#bit-shifting#accumulatortempo O(1)espaço O(1)20 minInput: value = 1Output: 2147483648Começar
- MédioValor único entre trios#bit-counting#modular-arithmetictempo O(n)espaço O(1)Entrar30 minInput: nums = [2, 2, 3, 2]Output: 3Começar
- FácilO valor que falta#xor-cancel#single-passtempo O(n)espaço O(1)20 minInput: nums = [3, 0, 1]Output: 2Começar
- FácilContagem de bits diferentes#xor#bit-countingtempo O(log max(a, b))espaço O(1)15 minInput: a = 1, b = 4Output: 2Começar
- FácilBits ligados de cada número#bit-shifting#reuse-smaller-answertempo O(n)espaço O(n)20 minInput: n = 5Output: [0, 1, 1, 2, 1, 2]Começar
- MédioDois valores solitários#xor-cancel#bit-partitiontempo O(n)espaço O(1)Entrar30 minInput: nums = [1, 2, 1, 3, 2, 5]Output: [3, 5]Começar
- FácilVerificar potência de quatro#bitmask#power-of-twotempo O(1)espaço O(1)15 minInput: n = 16Output: TrueComeçar
- FácilTodos os subconjuntos por bitmask#bitmask#subsetstempo O(n · 2ⁿ)espaço O(n · 2ⁿ)20 minInput: items = ["a", "b"]Output: [[], ['a'], ['b'], ['a', 'b']]Começar
- MédioOrdenar com trocas por contagem de bits#popcount#adjacent-swapstempo O(n log m)espaço O(1)Entrar25 minInput: nums = [6, 5, 3, 16, 8, 31]Output: TrueComeçar
- DifícilMenor percurso por todos os nós#bitmask#bfstempo O(n² · 2ⁿ)espaço O(n · 2ⁿ)Entrar45 minInput: adj = [[1, 3, 4], [0, 2], [1, 3, 5], [2, 0], [0], [2]]Output: 6Começar
- MédioSomar dois números sem o sinal de mais#bitwise-add#carry-propagation#twos-complementtempo O(1)espaço O(1)Entrar25 minInput: a = 1, b = 2Output: 3Começar
- MédioAND bit a bit em um intervalo#common-prefix#bit-shifttempo O(1)espaço O(1)Entrar20 minInput: lo = 5, hi = 7Output: 4Começar
- MédioPares de palavras sem letras em comum#bitmask#set-as-integertempo O(L + n²)espaço O(n)Entrar20 minInput: words = ["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]Output: 16Começar
- MédioSoma das diferenças de bits entre pares#bit-counting#per-bit-contributiontempo O(n)espaço O(1)Entrar20 minInput: nums = [4, 14, 2]Output: 6Começar
Tópico · Matemática e teoria dos números
0 / 13 concluídos- FácilZeros finais de um fatorial#factor-counting#mathtempo O(log n)espaço O(1)20 minInput: n = 5Output: 1Começar
- MédioPrimos abaixo de um limite#sieve#precomputationtempo O(n log log n)espaço O(n)Entrar25 minInput: limit = 10Output: 4Começar
- MédioPotência modular#fast-exponentiation#modular-arithmetictempo O(log exp)espaço O(1)Entrar25 minInput: base = 2, exp = 10, mod = 1000Output: 24Começar
- FácilSoma repetida dos dígitos#modular-arithmetic#mathtempo O(1)espaço O(1)15 minInput: n = 38Output: 2Começar
- MédioMedir com dois jarros#gcd#mathtempo O(log min(a, b))espaço O(1)Entrar25 minInput: a = 3, b = 5, t = 4Output: TrueComeçar
- MédioCombinações módulo um primo#combinatorics#modular-inversetempo O(min(k, n − k) + log p)espaço O(1)Entrar30 minInput: n = 5, k = 2Output: 10Começar
- FácilMínimo múltiplo comum de uma lista#gcd#lcmtempo O(n log(max(nums)))espaço O(1)15 minInput: nums = [4, 6, 10]Output: 60Começar
- MédioFração como dízima periódica#long-division#hash-maptempo O(den)espaço O(den)Entrar30 minInput: num = 1, den = 6Output: "0.1(6)"Começar
- DifícilPrimos em um intervalo amplo#segmented-sieve#sievetempo O((√hi + hi − lo) log log hi)espaço O(√hi + hi − lo)Entrar40 minInput: lo = 10, hi = 30Output: 6Começar
- FácilUma linha do triângulo de Pascal#binomial-coefficients#multiplicative-formulatempo O(k)espaço O(k)15 minInput: k = 3Output: [1, 3, 3, 1]Começar
- FácilGreatest Common Divisor of Strings#gcd#string-periodtempo O(len(a) + len(b))espaço O(len(a) + len(b))15 minInput: a = "ABCABC", b = "ABC"Output: "ABC"Começar
- MédioPares de músicas em minutos inteiros#modular-arithmetic#remainder-counttempo O(n)espaço O(1)Entrar20 minInput: times = [30, 20, 150, 100, 40]Output: 3Começar
- MédioPotência com um expoente gigante#fast-exponentiation#modular-arithmetictempo O(len(b))espaço O(1)Entrar25 minInput: a = 2, b = [3]Output: 8Começar
Tópico · Programação dinâmica
0 / 27 concluídos- FácilSubida de escada mais barata#bottom-up-dp#rolling-variablestempo O(n)espaço O(1)20 minInput: cost = [10, 15, 20]Output: 15Começar
- MédioCaminhos no grid com bloqueios#grid-dp#bottom-up-dptempo O(rows · cols)espaço O(cols)Entrar30 minInput: [[0]]Output: 1Começar
- MédioSegmentação de frases#bottom-up-dp#hash-settempo O(L³)espaço O(L)Entrar30 minInput: text = applepen, words = [apple, pen]Output: TrueComeçar
- DifícilOperações com dia de espera#state-machine-dp#rolling-variablestempo O(n)espaço O(n)Entrar45 minInput: prices = [1, 2, 3, 0, 2]Output: 3Começar
- FácilPintar casas pelo menor preço#bottom-up-dp#rolling-variablestempo O(n)espaço O(1)20 minInput: costs = [[7, 6, 2]]Output: 2Começar
- MédioDecodificar mensagem de dígitos#bottom-up-dp#rolling-variablestempo O(n)espaço O(1)Entrar30 minInput: digits = "226"Output: 3Começar
- MédioFormatos distintos de BST#bottom-up-dp#countingtempo O(n²)espaço O(n)Entrar30 minInput: n = 3Output: 5Começar
- DifícilEstourar balões por moedas#interval-dp#bottom-up-dptempo O(n³)espaço O(n²)Entrar50 minInput: values = [3, 1, 5, 8]Output: 167Começar
- FácilColheita sem vizinhos#bottom-up-dp#rolling-variablestempo O(n)espaço O(1)20 minInput: yields = [2, 7, 9, 3, 1]Output: 12Começar
- MédioMenos moedas para um valor#bottom-up-dp#unbounded-knapsacktempo O(amount · len(coins))espaço O(amount)Entrar30 minInput: coins = [1, 4, 6], amount = 8Output: 2Começar
- MédioMaior subsequência crescente#bottom-up-dp#subsequence-dptempo O(n²)espaço O(n)Entrar30 minInput: nums = [4, 1, 3, 2, 5, 3, 6]Output: 4Começar
- MédioMenos edições entre palavras#string-dp#bottom-up-dptempo O(len(a) · len(b))espaço O(len(b))Entrar35 minInput: a = "carpet", b = "parrot"Output: 3Começar
- DifícilEnvelopes aninhados#binary-search#patience-sorting#sortingtempo O(n log n)espaço O(n)Entrar45 minInput: envelopes = [[4, 5], [4, 6], [6, 7], [2, 3], [1, 1]]Output: 4Começar
- DifícilCortes mais baratos em uma vareta#interval-dp#bottom-up-dptempo O(m³)espaço O(m²)Entrar50 minInput: length = 10, marks = [2, 4, 7]Output: 20Começar
- MédioFormas de pagar um valor#unbounded-knapsack#bottom-up-dptempo O(k · amount)espaço O(amount)Entrar25 minInput: coins = [2, 3, 5], amount = 10Output: 4Começar
- DifícilMontar a menor supersequência#string-dp#subsequence-dptempo O(len(a) · len(b))espaço O(len(a) · len(b))Entrar45 minInput: a = "tile", b = "style"Output: "stiyle"Começar
- MédioLongest Palindromic Subsequence#lcs#2d-dptempo O(n²)espaço O(n)Entrar30 minInput: s = "character"Output: 5Começar
- MédioSinais que atingem o alvo#0-1-knapsack#subset-counttempo O(n · sum(nums))espaço O(sum(nums))Entrar30 minInput: nums = [1, 2, 3, 4], target = 2Output: 2Começar
- DifícilMenos vigias em uma árvore#tree-dp#state-machinetempo O(n)espaço O(h)Entrar45 minInput: tree = 1, left 2, whose children are 3 and 4Output: 1Começar
- DifícilFatias de torta com dois amigos#circular-dp#exact-count-dptempo O(n²)espaço O(n)Entrar45 minInput: slices = [4, 1, 2, 8, 3, 5]Output: 13Começar
- MédioCarga de van de maior valor#unbounded-knapsack#bottom-up-dptempo O(W · len(crates))espaço O(W)Entrar25 minInput: W = 10, crates (weight, value) = [(3, 5), (4, 7), (6, 11)]Output: 18Começar
- MédioDivisão mais equilibrada em dois times#0-1-knapsack#subset-sumtempo O(n · sum(ratings))espaço O(sum(ratings))Entrar30 minInput: ratings = [5, 8, 13, 2]Output: 2Começar
- FácilVales-presente para um total exato#0-1-knapsack#subset-sumtempo O(n · total)espaço O(total)20 minInput: cards = [3, 34, 4, 12, 5, 2], total = 9Output: TrueComeçar
- FácilTroco exato com moedas ilimitadas#unbounded-knapsack#bottom-up-dptempo O(len(coins) · amount)espaço O(amount)15 minInput: coins = [4, 7], amount = 15Output: TrueComeçar
- FácilCaminho mais barato em um grid#grid-dp#2d-dptempo O(rows · cols)espaço O(rows · cols)20 minInput: grid = [[1, 3, 1], [1, 5, 1], [4, 2, 1]]Output: 7Começar
- FácilMenos remoções para igualar palavras#lcs#string-dptempo O(m · n)espaço O(m · n)20 minInput: a = "sea", b = "eat"Output: 2Começar
- MédioIntercalar duas strings#two-string-dp#rolling-rowtempo O(len(a) · len(b))espaço O(len(b))Entrar30 minInput: a = "aabcc", b = "dbbca", c = "aadbbcbcac"Output: TrueComeçar
Tópico · System design
0 / 8 concluídos- FácilRate limiter com token bucket#token-bucket#integer-mathtempo O(n)espaço O(n)15 minInput: capacity = 2, per_second = 1, times_ms = [0, 0, 0, 500, 1000, 3000]Output: [True, True, False, False, True, True]Começar
- FácilQuórum de leitura dado o de escrita#quorum#pigeonholetempo O(1)espaço O(1)10 minInput: n = 3, w = 2Output: (2, 1)Começar
- MédioAnel de hashing consistente#consistent-hashing#virtual-nodes#bisecttempo O(log p)espaço O(p)Entrar25 minInput: nodes = db-a, db-b, db-c; owner("user:42") before and after db-d joinsOutput: db-c db-cComeçar
- MédioDimensionamento de um filtro de Bloom#bloom-filter#double-hashingtempo O(k)espaço O(m)Entrar25 minInput: n = 1000, p = 0.01Output: (9586, 7)Começar
- MédioBalanceador de carga por menos conexões#least-connections#min-heap#event-simulationtempo O(n (log n + s))espaço O(n + s)Entrar25 minInput: servers = ["a", "b"], requests = [(0, 10), (1, 2), (2, 5), (3, 1), (4, 1)]Output: (['a', 'b', 'a', 'b', 'b'], {'a': 2, 'b': 1})Começar
- FácilPercentis de latência por nearest rank#percentiles#sortingtempo O(n log n + q)espaço O(n)10 minInput: latencies = [12, 15, 11, 13, 240, 14, 12, 16, 13, 12], ps = [50, 90, 99]Output: {50: 13, 90: 16, 99: 240}Começar
- MédioVisibility timeouts na fila de mensagens#message-queue#event-simulationtempo O(p · m)espaço O(p + m)Entrar25 minInput: messages = ["poison"], polls at 0, 10, 20 and 30 by "a", work = {"a": 99}, timeout = 10, max_receives = 3Output: ([(0, 'a', 'poison'), (10, 'a', 'poison'), (20, 'a', 'poison'), (30, 'a', None)], [], ['poison'])Começar
- MédioCaminho crítico de um trace#distributed-tracing#interval-union#tree-walktempo O(n log n)espaço O(n)Entrar25 minInput: [("r", None, "api", 0, 50), ("p", "r", "search", 0, 50), ("q", "r", "ads", 10, 30)]Output: ({'ads': 20, 'api': 0, 'search': 50}, ['r', 'p'])Começar
Tópico · Casos de system design
0 / 4 concluídos- FácilCapacidade de um encurtador de URL#capacity-estimation#back-of-the-envelopetempo O(log(total links))espaço O(1)15 minInput: new_per_day = 100_000_000, reads_per_write = 100, bytes_per_url = 500, years = 10, peak = 3Output: {'write_qps': 1158, 'read_qps': 115741, 'peak_read_qps': 347223, 'storage_tb': 182.5, 'code_length': 7}Começar
- MédioCusto do fan-out de um feed#fan-out#cost-modeltempo O(E + U)espaço O(E + U)Entrar25 minInput: the same graph and posts, but only ann opens the feed, once a dayOutput: ({'push': 93, 'pull': 4, 'hybrid': 14}, 'pull')Começar
- MédioNíveis de rate limit em um API Gateway#rate-limiting#sliding-window-logtempo O(r log n)espaço O(n)Entrar25 minInput: tiers = {"free": [(10, 1)]}, requests from "a" at 0, 9, 10, 19, 20Output: {'a': [3, 2]}Começar
- FácilTaxa de acerto do cache de um feed#lru-cache#hit-ratiotempo O(n)espaço O(c)15 minInput: feed = ["a", "b", "c", "a", "b", "c"], capacity = 2Output: 0.0Começar
Tópico · IA e ML
0 / 8 concluídos- FácilSoftmax com temperatura#softmax#numerical-stabilitytempo O(v)espaço O(v)15 minInput: logits = [2.0, 1.0, 0.1], temperature = 1.0Output: [0.659, 0.242, 0.099]Começar
- FácilOrçamento de memória do cache KV#capacity-math#memory-estimatetempo O(1)espaço O(1)10 minInput: layers = 32, kv_heads = 32, head_dim = 128, tokens = 4096, batch = 1, 2 bytes per numberOutput: 2048.0Começar
- MédioDocumentos mais próximos por cosseno#vector-math#partial-sorttempo O(n · d + n log k)espaço O(n)Entrar20 minInput: query = [2, 0, 0], k = 2, articles = b [1, 0, 0], a [3, 0, 0], c [0, 1, 0]Output: [('a', 1.0), ('b', 1.0)]Começar
- MédioCortar o chat para caber no contexto#token-budget#newest-firsttempo O(t)espaço O(1)Entrar20 minInput: budget = 100, system = 20, reserve = 25, turns = [10, 30, 10, 20, 15]Output: 2Começar
- DifícilAprender as mesclagens do BPE#byte-pair-encoding#pair-countingtempo O(m · L)espaço O(L)Entrar35 minInput: words = {"low": 5, "lower": 2, "newest": 6, "widest": 3}, merges = 4Output: [('e', 's'), ('es', 't'), ('l', 'o'), ('lo', 'w')]Começar
- FácilIda e volta da quantização int8#quantization#scale-and-roundtempo O(n)espaço O(n)15 minInput: [0.4, -2.54, 0.013, 1.0]Output: ([20, -127, 1, 50], 0.02, 0.007)Começar
- MédioPassadas na decodificação especulativa#speculative-decoding#draft-and-verifytempo O(n · k)espaço O(n)Entrar25 minInput: prompt = ["the"], draft guesses "a" after "on" where the target says "the", k = 4, n = 8Output: (['cat', 'sat', 'on', 'the', 'cat', 'sat', 'on', 'the'], 2)Começar
- DifícilRecall da busca com arquivo invertido#vector-search#inverted-file-index#recall-at-ktempo O(n · c + c · q · n log n)espaço O(n + c)Entrar35 minInput: the same vectors and centroids, queries = [(6, 1)], k = 2Output: [0.5, 1.0, 1.0]Começar
Tópico · Low-level design
0 / 8 concluídos- FácilCalculadora de tarifa de estacionamento#class-design#pricing-rules15 minInput: same lot, fee("car", 26 * 60)Output: 26Começar
- FácilMáquina de venda com moedas#class-design#state-machine15 minInput: then insert(100), select("A1"), select("A1")Output: ['credit 125', 'vend A1, change 60', 'sold out']Começar
- MédioCache LRU com expiração#ordered-dict#lazy-expiry#min-heaptempo O(log n)espaço O(number of puts)Entrar30 minInput: then get("a", now=10)Output: NoneComeçar
- MédioEvent bus com curingas no tópico#observer#topic-matchingtempo O(s · d)espaço O(s · d)Entrar25 minInput: then unsubscribe(the audit token), publish("order.created", "o8")Output: 0Começar
- DifícilSistema de arquivos em memória#class-design#path-walk#invariantsEntrar35 minInput: then read("/logs/app/today.txt"), size("/")Output: 'boot ok\nuser in\n' 23Começar
- FácilMelhor desconto no checkout#strategy-pattern#class-designtempo O(p · c)espaço O(1)15 minInput: cart = [("coffee", 1200, 3), ("mug", 900, 2)], all three promotionsOutput: ('buy 2 coffee get 1 free', 4200)Começar
- MédioParadas do elevador em varredura#elevator-sweep#event-simulationtempo O(F · p + r log r)espaço O(r)Entrar25 minInput: start = 3, requests = [(0, 5), (0, 1), (1, 4), (6, 2)]Output: [(1, 4), (2, 5), (6, 1), (7, 2)]Começar
- DifícilLances legais que protegem o rei#board-model#move-generation#check-detectiontempo O(P² · 27²)espaço O(P)Entrar35 minInput: {"h8": "k", "g7": "Q", "f6": "K"}, black to moveOutput: ('checkmate', [])Começar
Tópico · Concorrência
0 / 8 concluídos- FácilAtualizações perdidas no contador#race-condition#step-simulationtempo O(s)espaço O(t)15 minInput: threads = 2, schedule = [0, 0, 0, 1, 1, 1]Output: 2Começar
- FácilTamanho do pool de threads para a carga#capacity-math#integer-ceilingtempo O(1)espaço O(1)10 minInput: cores = 8, utilization = 100, wait_ms = 90, compute_ms = 10Output: 80Começar
- MédioThreads em deadlock no grafo de espera#wait-for-graph#cycle-detectiontempo O(t + l)espaço O(t)Entrar25 minInput: holds = {"a": "T1", "b": "T2"}, waits = {"T1": "b", "T2": "a"}Output: ['T1', 'T2']Começar
- MédioHorários de início atrás de um semáforo#min-heap#event-simulationtempo O(n log p)espaço O(n)Entrar20 minInput: permits = 2, jobs = [(0, 5), (1, 3), (2, 4), (3, 1)]Output: [0, 1, 4, 5]Começar
- DifícilEntregas em um buffer limitado#bounded-queue#event-simulation#fifo-fairnesstempo O(n)espaço O(n)Entrar35 minInput: capacity = 1, calls = put P1 a, put P2 b, take C1, take C2, take C1, put P1 cOutput: ([('C1', 'a'), ('C2', 'b'), ('C1', 'c')], [])Começar
- FácilRetries em um loop de compare-and-swap#compare-and-swap#step-simulationtempo O(s)espaço O(t)15 minInput: start = 0, amounts = [5, 7], schedule = [0, 1, 0, 1, 1, 1]Output: (12, [0, 1])Começar
- MédioHorários de término em um event loop#event-loop#min-heap#event-simulationtempo O(s log n)espaço O(n)Entrar25 minInput: [("api", 0, [2, 10, 1]), ("report", 1, [30]), ("ping", 3, [1])]Output: {'report': 32, 'ping': 33, 'api': 34}Começar
- MédioOrdem de locks que evita deadlock#lock-ordering#topological-sort#min-heaptempo O(E + L log L)espaço O(E + L)Entrar25 minInput: [["accounts", "ledger"], ["ledger", "audit"], ["accounts", "audit"]]Output: ['accounts', 'ledger', 'audit']Começar
Tópico · SQL
0 / 15 concluídos- FácilSecond Highest Salary#scalar-subquery#aggregate10 minInput: employee = [(1, "Ana", 300), (2, "Ben", 200), (3, "Cy", 100)]Output: [(200,)]Começar
- FácilE-mails usados mais de uma vez#group-by#having10 minInput: account = [(1, "a@x.io"), (2, "b@x.io"), (3, "a@x.io"), (4, "c@x.io"), (5, "b@x.io"), (6, "a@x.io")]Output: [("a@x.io", 3), ("b@x.io", 2)]Começar
- FácilClientes que nunca fizeram pedidos#left-join#anti-join15 minComeçar
- FácilGanha mais que o próprio gerente#self-join15 minInput: employee = [(1, "Ana", 120, None), (2, "Ben", 90, 1), (3, "Cleo", 130, 1), (4, "Dev", 95, 3), (5, "Finn", 100, 4)]Output: [("Cleo", 130, 120), ("Finn", 100, 95)]Começar
- MédioDepartamento com a maior média salarial#group-by#cte#tiesEntrar20 minInput: employee = [(1, "Ana", "eng", 120), (2, "Cleo", "eng", 130), (3, "Dev", "ops", 95), (4, "Finn", "ops", 100), (5, "Gus", "hr", 70)]Output: [("eng", 125.0)]Começar
- MédioDois maiores salários por departamento#window-function#top-n-per-groupEntrar25 minInput: employee = [(1, "Ana", "eng", 120), (2, "Ben", "eng", 90), (3, "Cleo", "eng", 130), (4, "Dev", "ops", 95), (5, "Eve", "ops", 80), (6, "Finn", "ops", 100)]Output: [("eng", "Cleo", 130), ("eng", "Ana", 120), ("ops", "Finn", 100), ("ops", "Dev", 95)]Começar
- MédioLivros por autor em uma só consulta#n-plus-one#left-join#group-byEntrar20 minComeçar
- MédioSaldo acumulado por conta#window-function#running-total#window-frameEntrar25 minInput: txn = [(1, "A", "2026-09-01", 100), (2, "B", "2026-09-01", 50), (3, "A", "2026-09-02", -30), (4, "A", "2026-09-02", 20), (5, "B", "2026-09-03", -50)]Output: [("A", "2026-09-01", 100, 100), ("A", "2026-09-02", -30, 70), ("A", "2026-09-02", 20, 90),Começar
- MédioLogin em três dias seguidos#window-function#consecutive-rows#dedupeEntrar25 minInput: login = [("kim", "2026-09-01"), ("kim", "2026-09-02"), ("kim", "2026-09-03"), ("lee", "2026-09-01"), ("lee", "2026-09-02"), ("lee", "2026-09-04")]Output: [("kim",)]Começar
- DifícilAgrupar um log de status em sequências#gaps-and-islands#window-function#row-numberEntrar35 minInput: status_log = [("2026-09-01", "up"), ("2026-09-02", "up"), ("2026-09-03", "down"), ("2026-09-04", "up"), ("2026-09-05", "up")]Output: [("up", "2026-09-01", "2026-09-02", 2), ("down", "2026-09-03", "2026-09-03", 1), ("up", "2026-09-04", "2026-09-05", 2)]Começar
- MédioMesma leitura três vezes seguidas#self-join#consecutive-rows#distinctEntrar20 minInput: reading = [(1, 1), (2, 1), (3, 1), (4, 2), (5, 1), (6, 2), (7, 2)]Output: [(1,)]Começar
- MédioMaior salário de cada departamento#correlated-subquery#max#tiesEntrar20 minInput: employee = [(1, "Ana", "eng", 120), (2, "Ben", "eng", 150), (3, "Cy", "ops", 90), (4, "Dee", "ops", 80)]Output: [("eng", "Ben", 150), ("ops", "Cy", 90)]Começar
- MédioClientes que compraram todos os produtos#group-by#having#count-distinctEntrar20 minInput: product = [5, 6], purchase = [(1, 5), (2, 6), (3, 5), (3, 6), (1, 6)]Output: [(1,), (3,)]Começar
- DifícilUsuários retidos mês a mês#cte#self-join#retentionEntrar35 minInput: activity = [(1, "2026-01-05"), (1, "2026-01-20"), (2, "2026-01-09"), (1, "2026-02-02"), (3, "2026-02-14"), (2, "2026-03-01"), (3, "2026-03-30")]Output: [("2026-01", 2, 0), ("2026-02", 2, 1), ("2026-03", 2, 1)]Começar
- FácilVendas trimestrais como colunas#pivot#case-when#group-by15 minInput: sales = [("east", 1, 100), ("east", 2, 50), ("west", 1, 70), ("east", 1, 30), ("west", 4, 20)]Output: [("east", 130, 50, 0, 0), ("west", 70, 0, 0, 20)]Começar