Practicar
370 problemas en 27 temas. Las pistas llegan una por una y la solución queda cerrada hasta que la pidas.
370 problemas
Tema · Arrays
0 / 20 completados- FácilUna sola operación de bolsa#single-pass#running-minimumtiempo O(n)espacio O(1)15 minInput: prices = [8, 3, 6, 1, 9, 4]Output: 8Empezar
- FácilQuitar duplicados de una lista ordenada#two-pointers#in-placetiempo O(n)espacio O(1)15 minInput: nums = [1, 1, 2, 3, 3, 3]Output: 3, and nums begins with [1, 2, 3]Empezar
- MediaProducto de los demás#prefix-products#two-passtiempo O(n)espacio O(n)Iniciar sesión25 minInput: nums = [2, 3, 4, 5]Output: [60, 40, 30, 24]Empezar
- MediaTramo sin repetidos más largo#sliding-window#hash-maptiempo O(n)espacio O(n)Iniciar sesión25 minInput: items = [1, 2, 3, 2, 4, 5]Output: 4Empezar
- DifícilMáximos por ventana#sliding-window#monotonic-dequetiempo O(n)espacio O(n)Iniciar sesión40 minInput: nums = [1, 4, 2, 7, 3, 3], k = 3Output: [4, 7, 7, 7]Empezar
- FácilValor mayoritario#counting#single-passtiempo O(n)espacio O(1)15 minInput: nums = [3, 3, 4]Output: 3Empezar
- MediaRotar k posiciones a la derecha#in-place#reversaltiempo O(n)espacio O(1)Iniciar sesión25 minInput: nums = [1, 2, 3, 4, 5, 6, 7], k = 3Output: [5, 6, 7, 1, 2, 3, 4]Empezar
- MediaRecorrido en espiral de una cuadrícula#matrix-traversal#boundary-shrinkingtiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión25 minInput: [[7]]Output: [7]Empezar
- FácilMover el valor objetivo al final#two-pointers#write-pointertiempo O(n)espacio O(1)15 minInput: nums = [4, 0, 7, 0, 2], v = 0Output: [4, 7, 2, 0, 0]Empezar
- MediaSubarray Sums Divisible by K#prefix-sums#hash-map#modular-arithmetictiempo O(n)espacio O(min(n, k))Iniciar sesión25 minInput: nums = [2, -2, 3, 1, 5], k = 3Output: 6Empezar
- DifícilMenor positivo ausente#cyclic-sort#index-as-hometiempo O(n)espacio O(1)Iniciar sesión35 minInput: nums = [5, 3, -1, 1, 2]Output: 4Empezar
- DifícilAgua retenida entre barras#two-pointers#running-maximumtiempo O(n)espacio O(1)Iniciar sesión35 minInput: heights = [3, 0, 2, 0, 4, 1, 2]Output: 8Empezar
- FácilCuadrados de una lista ordenada#two-pointers#merge-from-backtiempo O(n)espacio O(n)15 minInput: nums = [-5, -2, 1, 3, 4]Output: [1, 4, 9, 16, 25]Empezar
- FácilInvertir cada bloque de k#in-place-reversal#two-pointerstiempo O(n)espacio O(1)15 minInput: nums = [1, 2, 3, 4, 5, 6, 7, 8], k = 3Output: [3, 2, 1, 6, 5, 4, 7, 8]Empezar
- FácilÍndice del punto de equilibrio#prefix-sums#running-sumtiempo O(n)espacio O(1)15 minInput: values = [2, 7, 1, 5, 4]Output: 2Empezar
- MediaVentana más larga dentro del presupuesto#sliding-window#two-pointerstiempo O(n)espacio O(1)Iniciar sesión25 minInput: costs = [4, 1, 1, 3, 2, 6], budget = 6Output: 3Empezar
- FácilMás alto que todo lo que sigue#running-maximum#linear-scantiempo O(n)espacio O(n)15 minInput: heights = [16, 17, 4, 3, 5, 2]Output: [17, 5, 2]Empezar
- MediaTres valores que suman cero#two-pointers#sort-first#skip-duplicatestiempo O(n²)espacio O(n²)Iniciar sesión30 minInput: nums = [-1, 0, 1, 2, -1, -4]Output: [[-1, -1, 2], [-1, 0, 1]]Empezar
- MediaSiguiente disposición mayor#in-place-reversal#suffix-scantiempo O(n)espacio O(1)Iniciar sesión25 minInput: nums = [1, 3, 2]Output: [2, 1, 3]Empezar
- MediaSubarray de producto máximo#kadane#running-min-maxtiempo O(n)espacio O(n)Iniciar sesión25 minInput: nums = [2, 3, -2, 4]Output: 6Empezar
Tema · Strings
0 / 16 completados- FácilPrefijo común más largo#column-scan#string-comparisontiempo O(total characters)espacio O(len(words) + len(words[0]))15 minInput: words = ["flower", "flow", "flight"]Output: "fl"Empezar
- FácilPrimer carácter único#hash-map#two-passtiempo O(n)espacio O(k)15 minInput: text = "reference"Output: 2Empezar
- MediaCompresión por longitud de series#two-pointers#run-length-encodingtiempo O(n)espacio O(n)Iniciar sesión25 minInput: text = "aaabccdddd"Output: "a3bc2d4"Empezar
- MediaMultiplicar strings de dígitos#digit-arithmetic#carry-propagationtiempo O(len(a) · len(b))espacio O(len(a) + len(b))Iniciar sesión30 minInput: a = "123", b = "456"Output: "56088"Empezar
- DifícilVentana mínima de cobertura#sliding-window#hash-maptiempo O(len(text) + len(need))espacio O(len(text) + len(need))Iniciar sesión45 minInput: text = "ADOBECODEBANC", need = "ABC"Output: "BANC"Empezar
- MediaAgrupar anagramas#hash-map#canonical-formtiempo O(n · k log k)espacio O(n · k)Iniciar sesión20 minInput: words = ["eat", "tea", "tan", "ate", "nat", "bat"]Output: [["ate", "eat", "tea"], ["bat"], ["nat", "tan"]]Empezar
- MediaRepeated DNA Sequences#rolling-hash#hash-settiempo O(n)espacio O(n)Iniciar sesión30 minInput: dna = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"Output: ["AAAAACCCCC", "CCCCCAAAAA"]Empezar
- FácilPalíndromo tras una eliminación#two-pointers#greedytiempo O(n)espacio O(1)20 minInput: s = "racexcar"Output: TrueEmpezar
- FácilInvertir el orden de las palabras#two-pointers#word-splittiempo O(n)espacio O(n)10 minInput: s = " the sky is blue "Output: "blue is sky the"Empezar
- DifícilPalíndromo más corto agregando al inicio#kmp#palindrometiempo O(n)espacio O(n)Iniciar sesión40 minInput: s = "abacd"Output: "dcabacd"Empezar
- MediaContar substrings palindrómicos#expand-around-center#palindrometiempo O(n²)espacio O(1)Iniciar sesión25 minInput: s = "level"Output: 7Empezar
- MediaUnidad mínima que se repite#kmp#string-periodtiempo O(n)espacio O(n)Iniciar sesión25 minInput: s = "xyzxyzxyz"Output: "xyz"Empezar
- DifícilCuántas veces aparece cada prefijo#z-algorithm#suffix-sumstiempo O(n)espacio O(n)Iniciar sesión40 minInput: s = "abacaba"Output: [4, 2, 2, 1, 1, 1, 1]Empezar
- FácilEmpaquetar palabras en un solo string#length-prefix#string-parsingtiempo O(L)espacio O(L)20 minInput: words = ["hi", "#1"]Output: pack -> "2#hi2##1"Empezar
- MediaPosiciones de anagramas en un texto#fixed-sliding-window#frequency-counttiempo O(len(text) + len(key))espacio O(len(text))Iniciar sesión25 minInput: text = "cbaebabacd", key = "abc"Output: [0, 6]Empezar
- FácilDe número romano a entero#string-scan#lookup-tabletiempo O(n)espacio O(1)15 minInput: s = "LVIII"Output: 58Empezar
Tema · Búsqueda
0 / 13 completados- FácilRaíz cuadrada entera#binary-search#monotonic-predicatetiempo O(log n)espacio O(1)20 minInput: n = 8Output: 2Empezar
- MediaPico en una lista irregular#binary-search#slope-followingtiempo O(log n)espacio O(1)Iniciar sesión30 minInput: nums = [1, 2, 3, 1]Output: 2Empezar
- DifícilMediana de dos listas ordenadas#binary-search#partitioningtiempo O(log min(m, n))espacio O(1)Iniciar sesión50 minInput: a = [1, 3], b = [2]Output: 2.0Empezar
- MediaPrimera y última aparición#binary-search#boundary-searchtiempo O(log n)espacio O(1)Iniciar sesión25 minInput: nums = [5, 7, 7, 8, 8, 10], target = 8Output: (3, 4)Empezar
- MediaCapacidad diaria mínima#binary-search-on-answer#greedy-checktiempo O(n log(sum(weights)))espacio O(1)Iniciar sesión30 minInput: weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], days = 5Output: 15Empezar
- FácilLas dos palabras más cercanas#single-pass#linear-scantiempo O(n)espacio O(1)15 minInput: words = ["cat", "dog", "fox", "cat", "owl", "dog"], a = "cat", b = "dog"Output: 1Empezar
- MediaContar las rotaciones#binary-search#boundary-searchtiempo O(log n)espacio O(1)Iniciar sesión20 minInput: nums = [15, 18, 2, 3, 6, 12]Output: 2Empezar
- MediaBuscar sin conocer la longitud#binary-search#exponential-searchtiempo O(log p)espacio O(1)Iniciar sesión25 minInput: values = [2, 5, 5, 9, 14, 20, 31], target = 9Output: 3Empezar
- FácilK-ésimo número que falta en una lista#binary-search#countingtiempo O(log n)espacio O(1)20 minInput: nums = [2, 3, 4, 7, 11], k = 5Output: 9Empezar
- MediaValor en un instante dado#binary-search#upper-bound#versioned-storetiempo O(log v)espacio O(number of set calls)Iniciar sesión25 minInput: set("port", "80", 10), get("port", 9), get("port", 10)Output: ["", "80"]Empezar
- FácilSiguiente letra después del objetivo#binary-search#upper-boundtiempo O(log n)espacio O(1)15 minInput: letters = ["c", "f", "j"], target = "a"Output: "c"Empezar
- MediaObjetivo en una lista ordenada rotada#binary-search#rotated-arraytiempo O(log n)espacio O(1)Iniciar sesión20 minInput: nums = [4, 5, 6, 7, 0, 1, 2], target = 0Output: 4Empezar
- DifícilK-ésima menor distancia entre pares#binary-search-on-answer#two-pointers#sortingtiempo O(n log n + n log(max − min))espacio O(n)Iniciar sesión35 minInput: nums = [1, 3, 1], k = 1Output: 0Empezar
Tema · Ordenamiento
0 / 15 completados- FácilPosiciones fuera de lugar#sorting#pairwise-comparisontiempo O(n log n)espacio O(n)15 minInput: heights = [1, 1, 4, 2, 1, 3]Output: 3Empezar
- MediaOrdenar en tres franjas#dutch-national-flag#in-placetiempo O(n)espacio O(1)Iniciar sesión30 minInput: values = [2, 0, 2, 1, 1, 0]Output: [0, 0, 1, 1, 2, 2]Empezar
- MediaFormar el número más grande#custom-comparator#sortingtiempo O(n log n)espacio O(n)Iniciar sesión30 minInput: nums = [3, 30, 34, 5, 9]Output: "9534330"Empezar
- MediaÍndice h a partir de las citas#sorting#countingtiempo O(n log n)espacio O(1)Iniciar sesión20 minInput: citations = [3, 0, 6, 1, 5]Output: 3Empezar
- DifícilBrecha máxima con buckets#bucket-sort#pigeonholetiempo O(n log n)espacio O(n)Iniciar sesión40 minInput: nums = [3, 6, 9, 1]Output: 3Empezar
- FácilDesplazamientos de insertion sort#insertion-sort#stable-sorttiempo O(n²)espacio O(n)15 minInput: nums = [3, 1, 2]Output: 2Empezar
- MediaOrdenar una cadena enlazada#divide-and-conquer#fast-slow-pointerstiempo O(n log n)espacio O(log n)Iniciar sesión30 minInput: 4 -> 1 -> 3 -> 1 -> 2Output: 1 -> 1 -> 2 -> 3 -> 4Empezar
- MediaMínimo de intercambios para ordenar#cycle-decomposition#selection-sorttiempo O(n log n)espacio O(n)Iniciar sesión25 minInput: nums = [4, 3, 1, 2]Output: 3Empezar
- MediaK-ésimo menor por partición#quickselect#three-way-partitiontiempo O(n)espacio O(n)Iniciar sesión30 minInput: nums = [7, 2, 9, 4, 4, 1], k = 3Output: 4Empezar
- FácilPares por debajo de un presupuesto#sorting#two-pointerstiempo O(n log n)espacio O(n)20 minInput: prices = [4, -2, 0, 3, 1], budget = 3Output: 5Empezar
- MediaOrden tras k pasadas por dígito#radix-sort#stable-sort#bucket-sorttiempo O(k · n)espacio O(n)Iniciar sesión25 minInput: nums = [53, 7, 318, 90, 41, 206, 17], k = 1Output: [90, 41, 53, 206, 7, 17, 318]Empezar
- DifícilContar pares desordenados#merge-sort#divide-and-conquer#inversion-counttiempo O(n log n)espacio O(n)Iniciar sesión35 minInput: nums = [2, 4, 1, 3, 5]Output: 3Empezar
- FácilOrdenar según el orden de otra lista#counting-sort#custom-ordertiempo O(n + k)espacio 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]Empezar
- MediaOrdenar volteando panqueques#selection-sort#prefix-reversaltiempo O(n²)espacio O(n)Iniciar sesión25 minInput: arr = [3, 2, 4, 1]Output: [3, 4, 2, 3, 2]Empezar
- FácilPares con la menor diferencia#sort-first#adjacent-scantiempo O(n log n)espacio O(n)15 minInput: nums = [4, 2, 1, 3]Output: [[1, 2], [2, 3], [3, 4]]Empezar
Tema · Listas enlazadas
0 / 14 completados- FácilFusionar cadenas ordenadas#two-pointers#dummy-nodetiempo O(n + m)espacio O(1)20 minInput: a = 1 -> 4 -> 6, b = 2 -> 3Output: 1 -> 2 -> 3 -> 4 -> 6Empezar
- MediaQuitar el n-ésimo desde el final#fast-slow-pointers#dummy-nodetiempo O(L)espacio O(1)Iniciar sesión25 minInput: head = 1 -> 2 -> 3 -> 4 -> 5, n = 2Output: 1 -> 2 -> 3 -> 5Empezar
- MediaEntrelazar las mitades de una lista#fast-slow-pointers#list-reversaltiempo O(n)espacio O(1)Iniciar sesión35 minInput: head = 1 -> 2 -> 3 -> 4Output: 1 -> 4 -> 2 -> 3Empezar
- FácilEliminar los nodos con un valor#dummy-node#pointer-relinkingtiempo O(n)espacio O(1)15 minInput: head = 1 -> 2 -> 6 -> 3 -> 6, target = 6Output: 1 -> 2 -> 3Empezar
- MediaSumar dos cadenas de dígitos#dummy-node#carry-propagationtiempo O(max(m, n))espacio O(max(m, n))Iniciar sesión25 minInput: a = 2 -> 4 -> 3, b = 5 -> 6 -> 4Output: 7 -> 0 -> 8Empezar
- MediaParticionar alrededor de un valor#dummy-node#list-splittingtiempo O(n)espacio O(1)Iniciar sesión30 minInput: head = 1 -> 4 -> 3 -> 2 -> 5 -> 2, pivot = 3Output: 1 -> 2 -> 2 -> 4 -> 3 -> 5Empezar
- FácilCiclo en una cadena#fast-slow-pointers#cycle-detectiontiempo O(n)espacio O(1)15 minInput: values = [3, 2, 0, -4], pos = 1Output: TrueEmpezar
- FácilHistorial de atrás y adelante#doubly-linked-list#designtiempo O(n + Σk)espacio O(n)20 minInput: home = "x", ops = [("back", 2), ("forward", 3)]Output: ['x', 'x']Empezar
- MediaDónde empieza el ciclo#fast-slow-pointers#cycle-detectiontiempo O(n)espacio O(1)Iniciar sesión30 minInput: values = [3, 2, 0, -4], pos = 1Output: 2Empezar
- MediaClonar una cadena con enlaces de salto#pointer-relinking#in-placetiempo O(n)espacio O(n)Iniciar sesión30 minInput: chain = [(3, None), (8, 0), (5, 3), (1, 1)]Output: [(3, None), (8, 0), (5, 3), (1, 1)], built from new nodes onlyEmpezar
- FácilUna cadena que se lee igual al revés#fast-slow-pointers#in-place-reversaltiempo O(n)espacio O(1)20 minInput: 1 -> 2 -> 2 -> 1Output: TrueEmpezar
- MediaCaché de uso menos reciente#doubly-linked-list#hash-map#sentinel-nodestiempo O(1)espacio O(capacity)Iniciar sesión35 minEmpezar
- DifícilInvertir nodos en grupos de k#in-place-reversal#dummy-headtiempo O(n)espacio O(1)Iniciar sesión35 minInput: list = 1 -> 2 -> 3 -> 4 -> 5, k = 2Output: 2 -> 1 -> 4 -> 3 -> 5Empezar
- FácilDónde se unen dos cadenas#two-pointers#list-traversaltiempo O(m + n)espacio O(1)15 minInput: a = 2 -> 6 -> 4, b = 1 -> 5, no shared nodesOutput: NoneEmpezar
Tema · Pilas y colas
0 / 15 completados- FácilPila de mínimo en tiempo constante#stack#auxiliary-stacktiempo O(1)espacio O(n)20 minEmpezar
- MediaDías hasta que haga más calor#monotonic-stacktiempo O(n)espacio O(n)Iniciar sesión30 minInput: temps = [30, 32, 31, 35]Output: [1, 2, 1, 0]Empezar
- FácilEliminar pares adyacentes#stack#string-scantiempo O(n)espacio O(n)15 minInput: text = "abbaca"Output: "ca"Empezar
- MediaDecodificar repeticiones anidadas#stack#string-parsingtiempo O(output · depth)espacio O(output + depth)Iniciar sesión30 minInput: text = "3[a]2[bc]"Output: "aaabcbc"Empezar
- DifícilMayor rectángulo entre barras#monotonic-stacktiempo O(n)espacio O(n)Iniciar sesión45 minInput: heights = [2, 1, 5, 6, 2, 3]Output: 10Empezar
- FácilSolicitudes en la última ventana#queue#sliding-windowtiempo O(n)espacio O(n)15 minInput: times = [0, 400, 900, 1000, 1400], w = 1000Output: [1, 2, 3, 3, 3]Empezar
- FácilOperaciones de una cola con dos pilas#two-stacks#amortizedtiempo O(m)espacio O(m)15 minInput: ops = [["push", 7], ["pop"], ["push", 8], ["push", 9], ["peek"]]Output: [7, 8]Empezar
- MediaDeque sobre un buffer circular#circular-buffer#designtiempo O(1)espacio O(capacity)Iniciar sesión25 minEmpezar
- FácilEvaluar tokens en notación posfija#stack#expression-evaluationtiempo O(n)espacio O(n)15 minInput: tokens = ["2", "1", "+", "3", "*"]Output: 9Empezar
- MediaRocas que chocan en una fila#stack#pop-while-weakertiempo O(n)espacio O(n)Iniciar sesión25 minInput: rocks = [5, 10, -5]Output: [5, 10]Empezar
- DifícilEvaluar sumas con paréntesis#stack#expression-parsing#sign-trackingtiempo O(n)espacio O(depth)Iniciar sesión40 minInput: s = "1 + 1"Output: 2Empezar
- FácilBúsqueda del siguiente valor mayor#monotonic-stack#hash-maptiempo O(n + q)espacio O(n + q)15 minInput: nums = [4, 1, 3, 6, 2, 5], queries = [1, 3, 2, 6]Output: [3, 6, 5, -1]Empezar
- FácilPrecios tras el siguiente descuento#monotonic-stack#next-smallertiempo O(n)espacio O(n)15 minInput: prices = [8, 4, 6, 2, 3]Output: [4, 2, 4, 2, 3]Empezar
- MediaSimplificar una ruta de Unix#stack#string-parsingtiempo O(n)espacio O(n)Iniciar sesión20 minInput: path = "/a/./b/../../c/"Output: "/c"Empezar
- DifícilTramo más corto con suma de al menos k#monotonic-deque#prefix-sumtiempo O(n)espacio O(n)Iniciar sesión40 minInput: nums = [2, -1, 2], k = 3Output: 3Empezar
Tema · Tablas hash
0 / 14 completados- FácilComprobar valores repetidos#hash-set#single-passtiempo O(n)espacio O(n)10 minInput: items = [4, 1, 9, 1]Output: TrueEmpezar
- MediaSubarrays que suman k#prefix-sums#hash-maptiempo O(n)espacio O(n)Iniciar sesión30 minInput: nums = [1, 2, 3, 1], k = 3Output: 2Empezar
- MediaRacha consecutiva más larga#hash-set#countingtiempo O(n)espacio O(n)Iniciar sesión30 minInput: nums = [9, 4, 2, 3, 1, 8]Output: 4Empezar
- FácilValores comunes de dos listas#hash-set#membership-testtiempo O(n + m)espacio O(m)15 minInput: a = [1, 2, 2, 1], b = [2, 2]Output: [2]Empezar
- FácilComprobar un renombrado consistente#hash-map#bijectiontiempo O(n)espacio O(n)20 minInput: a = "egg", b = "add"Output: TrueEmpezar
- MediaTuplas de cuatro listas que suman cero#hash-map#meet-in-the-middletiempo O(n²)espacio O(n²)Iniciar sesión30 minInput: a = [1, 2], b = [-2, -1], c = [-1, 2], d = [0, 2]Output: 2Empezar
- FácilDistancia de la repetición más cercana#hash-map#single-passtiempo O(n)espacio O(n)15 minInput: values = [7, 1, 3, 7, 1, 7]Output: 2Empezar
- MediaDónde cae cada clave con sondeo lineal#open-addressing#union-findtiempo O(m + n log m)espacio O(m)Iniciar sesión30 minInput: m = 7, keys = [10, 3, 17, 24, 5]Output: [3, 4, 5, 6, 0]Empezar
- MediaOrdenar letras por frecuencia#bucket-sort#countingtiempo O(n)espacio O(n)Iniciar sesión20 minInput: text = "banana"Output: "aaannb"Empezar
- DifícilCaché de uso menos frecuente#design#hash-map#frequency-bucketstiempo O(1)espacio O(capacity)Iniciar sesión45 minEmpezar
- MediaMayor tramo balanceado de ceros y unos#prefix-sum#first-seen-indextiempo O(n)espacio O(n)Iniciar sesión20 minInput: bits = [0, 1, 0]Output: 2Empezar
- FácilContar pares con una diferencia dada#hash-map#complement-lookuptiempo O(n)espacio O(n)15 minInput: nums = [3, 1, 4, 1, 5], k = 2Output: 2Empezar
- FácilNota de rescate con letras de revista#frequency-count#hash-maptiempo O(n + m)espacio O(1)10 minInput: note = "aab", banner = "baa"Output: TrueEmpezar
- MediaAgrupar palabras por desplazamiento#canonical-key#hash-map#groupingtiempo O(n · L)espacio O(n · L)Iniciar sesión20 minInput: words = ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"]Output: [["abc", "bcd", "xyz"], ["acef"], ["az", "ba"], ["a", "z"]]Empezar
Tema · Recursión
0 / 14 completados- FácilAplanar una lista anidada#recursion#tree-walktiempo O(n)espacio O(n)15 minInput: items = [1, [2, [3, 4]], 5]Output: [1, 2, 3, 4, 5]Empezar
- MediaMovimientos de una torre de discos#recursion#divide-and-conquertiempo O(2ⁿ)espacio O(2ⁿ)Iniciar sesión20 minInput: n = 1, src = "A", dst = "C", spare = "B"Output: [("A", "C")]Empezar
- MediaPotencia rápida#recursion#divide-and-conquertiempo O(log |exp|)espacio O(log |exp|)Iniciar sesión20 minInput: base = 2, exp = 10Output: 1024Empezar
- FácilSuma anidada ponderada por profundidad#recursion#pass-downtiempo O(n)espacio O(d)15 minInput: items = [[1, 1], 2, [1, 1]]Output: 10Empezar
- MediaSímbolo en una fila que se duplica#recursion#halvingtiempo O(n)espacio O(n)Iniciar sesión25 minInput: n = 4, k = 5Output: 1Empezar
- MediaTodas las formas de poner paréntesis#divide-and-conquer#memoizationtiempo O(4ⁿ / √n)espacio O(4ⁿ / √n)Iniciar sesión30 minInput: expr = "2-1-1"Output: [0, 2]Empezar
- MediaK-ésima clave menor de un BST, iterativa#explicit-stack#inordertiempo O(h + k)espacio O(h)Iniciar sesión25 minInput: same tree; k = 8Output: 14Empezar
- FácilPasos de dividir a la mitad o restar uno#tail-recursion#bit-countingtiempo O(log n)espacio O(1)15 minInput: n = 14Output: 6Empezar
- FácilTérmino de la secuencia look-and-say#recursion#run-lengthtiempo O(1.31ⁿ)espacio O(1.31ⁿ)15 minInput: n = 4Output: "1211"Empezar
- MediaNúmeros iguales al girarlos 180 grados#recursion#build-from-inside-outtiempo O(n · 5^(n/2))espacio O(n · 5^(n/2))Iniciar sesión25 minInput: n = 2Output: ["11", "69", "88", "96"]Empezar
- FácilN-ésimo número de Tribonacci#recurrence#rolling-statetiempo O(n)espacio O(1)10 minInput: n = 4Output: 4Empezar
- DifícilVerificar un string revuelto#recursion#memoization#divide-and-conquertiempo O(n⁴ log n)espacio O(n³)Iniciar sesión40 minInput: s1 = "great", s2 = "rgeat"Output: TrueEmpezar
- MediaÚltimo amigo que queda en el círculo#recursion#josephus#recurrencetiempo O(n)espacio O(1)Iniciar sesión25 minInput: n = 5, k = 2Output: 3Empezar
- FácilPalíndromo ignorando la puntuación#tail-recursion#two-pointerstiempo O(n)espacio O(1)15 minInput: s = "A man, a plan, a canal: Panama"Output: TrueEmpezar
Tema · Backtracking
0 / 14 completados- MediaPalabras del teclado telefónico#backtracking#decision-treetiempo O(n · 3ⁿ)espacio O(n · 3ⁿ)Iniciar sesión20 minInput: digits = "23"Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]Empezar
- MediaCombinaciones con suma objetivo#backtracking#pruningtiempo O(n^(target / min))espacio O(n^(target / min))Iniciar sesión25 minInput: nums = [2, 3, 6, 7], target = 7Output: [[2, 2, 3], [7]]Empezar
- MediaDividir en palíndromos#backtracking#pruningtiempo O(n · 2ⁿ)espacio O(n · 2ⁿ)Iniciar sesión25 minInput: s = "aab"Output: [["a", "a", "b"], ["aa", "b"]]Empezar
- FácilVariantes de mayúsculas y minúsculas#backtracking#include-excludetiempo O(n · 2^L)espacio O(n · 2^L)15 minInput: s = "a1b"Output: ["a1b", "a1B", "A1b", "A1B"]Empezar
- MediaStrings de paréntesis balanceados#backtracking#pruningtiempo O(4ⁿ / √n)espacio O(4ⁿ / √n)Iniciar sesión25 minInput: n = 3Output: ["((()))", "(()())", "(())()", "()(())", "()()()"]Empezar
- DifícilContar ubicaciones de reinas#backtracking#constraint-setstiempo O(n!)espacio O(n)Iniciar sesión40 minInput: n = 4Output: 2Empezar
- MediaPermutaciones distintas#backtracking#pruning#sortingtiempo O(n · n!)espacio O(n · n!)Iniciar sesión30 minInput: vals = [1, 2, 1]Output: [[1, 1, 2], [1, 2, 1], [2, 1, 1]]Empezar
- MediaDirecciones con puntos desde dígitos#backtracking#pruningtiempo O(1)espacio O(1)Iniciar sesión30 minInput: s = "25525511135"Output: ["255.255.11.135", "255.255.111.35"]Empezar
- DifícilCompletar un sudoku#backtracking#constraint-setsIniciar sesión45 minInput: the first row is "11......." and the rest are emptyOutput: FalseEmpezar
- DifícilFósforos en un cuadrado#backtracking#pruning#k-way-partitiontiempo O(4ⁿ)espacio O(n)Iniciar sesión40 minInput: sticks = [1, 1, 2, 2, 2]Output: TrueEmpezar
- FácilStrings binarios sin unos adyacentes#backtracking#pruningtiempo O(n · 1.62ⁿ)espacio O(n · 1.62ⁿ)15 minInput: n = 3Output: ["000", "001", "010", "100", "101"]Empezar
- MediaTrazar una palabra en una cuadrícula#backtracking#grid-dfs#pruningtiempo O(rows · cols · 3^L)espacio O(rows · cols + L)Iniciar sesión25 minInput: board = ["ABCE", "SFCS", "ADEE"], word = "ABCCED"Output: TrueEmpezar
- FácilElegir k de los primeros n números#backtracking#combinations#pruningtiempo O(k · C(n, k))espacio O(k · C(n, k))15 minInput: n = 4, k = 2Output: [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]Empezar
- FácilPermutaciones de dígitos hasta un límite#backtracking#permutations#pruningtiempo O(n · n!)espacio O(n!)15 minInput: digits = [3, 1, 2], limit = 300Output: [123, 132, 213, 231]Empezar
Tema · Algoritmos greedy
0 / 13 completados- MediaMenos eliminaciones sin choques#greedy#interval-scheduling#sortingtiempo O(n log n)espacio O(1)Iniciar sesión20 minInput: spans = [(1, 2), (2, 3), (3, 4), (1, 3)]Output: 1Empezar
- MediaMenos saltos hasta el final#greedy#reach-frontiertiempo O(n)espacio O(1)Iniciar sesión20 minInput: nums = [2, 3, 1, 1, 4]Output: 2Empezar
- MediaDividir un string en bloques#greedy#last-occurrencetiempo O(n)espacio O(1)Iniciar sesión20 minInput: s = "abacdc"Output: [3, 3]Empezar
- FácilRepartir galletas#greedy#sorting#two-pointerstiempo O(n log n + m log m)espacio O(n + m)15 minInput: wants = [1, 2, 3], sizes = [1, 1]Output: 1Empezar
- MediaRuta circular de combustible#greedy#running-sumtiempo O(n)espacio O(1)Iniciar sesión25 minInput: fuel = [1, 2, 3, 4, 5], cost = [3, 4, 5, 1, 2]Output: 3Empezar
- DifícilReparto justo de dulces#greedy#two-passtiempo O(n)espacio O(n)Iniciar sesión40 minInput: scores = [1, 0, 2]Output: 5Empezar
- MediaUnir cuerdas al menor costo#greedy#min-heaptiempo O(n log n)espacio O(n)Iniciar sesión25 minInput: lengths = [4, 3, 2, 6]Output: 29Empezar
- FácilRepartir candidatos entre dos ciudades#greedy#sort-by-differencetiempo O(n log n)espacio O(n)20 minInput: costs = [[10, 20], [30, 200], [400, 50], [30, 20]]Output: 110Empezar
- MediaMáximo de eventos a los que asistir#greedy#min-heap#earliest-deadlinetiempo O(n log n)espacio O(n)Iniciar sesión30 minInput: events = [[1, 2], [2, 3], [3, 4], [1, 2]]Output: 4Empezar
- MediaMenos clips para cubrir una transmisión#greedy#reach-frontier#interval-covertiempo O(n + T)espacio O(T)Iniciar sesión25 minInput: clips = [[0, 2], [4, 6], [8, 10], [1, 9], [1, 5], [5, 9]], T = 10Output: 3Empezar
- FácilMenor inicio para un recorrido positivo#running-sum#prefix-minimumtiempo O(n)espacio O(1)10 minInput: nums = [-3, 2, -3, 4, 2]Output: 5Empezar
- MediaCadena de pares más larga#greedy#sort-by-end#interval-schedulingtiempo O(n log n)espacio O(n)Iniciar sesión20 minInput: pairs = [[1, 2], [2, 3], [3, 4]]Output: 2Empezar
- Fácil¿Se puede alcanzar el último índice?#greedy#farthest-reachtiempo O(n)espacio O(1)15 minInput: jumps = [2, 3, 1, 1, 4]Output: TrueEmpezar
Tema · Árboles y BST
0 / 17 completados- FácilNiveles hasta la hoja más profunda#dfs#recursiontiempo O(n)espacio O(h)15 minInput: tree = 3 with children 9 and 20, where 20 has children 15 and 7Output: 3Empezar
- MediaRecorrido por niveles en zigzag#bfs#level-ordertiempo O(n)espacio O(n)Iniciar sesión30 minInput: tree = 3 with children 9 and 20, where 20 has children 15 and 7Output: [[3], [20, 9], [15, 7]]Empezar
- MediaVista desde la derecha#bfs#level-ordertiempo O(n)espacio O(n)Iniciar sesión25 minInput: tree = 1, left child 2 with right child 5, right child 3 with right child 4Output: [1, 3, 4]Empezar
- FácilComprobar la simetría especular#recursion#paired-traversaltiempo O(n)espacio O(h)20 minInput: tree = 1, left 2 with children 3 and 4, right 2 with children 4 and 3Output: TrueEmpezar
- FácilSuma objetivo de raíz a hoja#dfs#recursiontiempo O(n)espacio O(h)20 minInput: tree = 1 with a single left child 2; target = 1Output: FalseEmpezar
- MediaCamino más largo entre dos nodos#dfs#post-ordertiempo O(n)espacio O(h)Iniciar sesión30 minInput: tree = 1 with left child 2 having children 4 and 5, and right child 3Output: 3Empezar
- DifícilReconstruir a partir de dos recorridos#divide-and-conquer#hash-map#recursiontiempo O(n)espacio O(n)Iniciar sesión45 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 7Empezar
- FácilClave más cercana en un BST#bst#search-pathtiempo O(h)espacio O(1)15 minInput: same tree; target = 12.2Output: 14Empezar
- MediaDistancia entre dos claves de un BST#bst#lowest-common-ancestortiempo O(h)espacio O(1)Iniciar sesión25 minInput: same tree; a = 6, b = 7Output: 1Empezar
- FácilProfundidad mínima hasta una hoja#bfs#level-ordertiempo O(n)espacio O(w)15 minInput: tree = 6, left 2 (whose left is 1, whose left is 0), right 9Output: 2Empezar
- MediaAplanar un árbol en una cadena#preorder#explicit-stacktiempo O(n)espacio O(h)Iniciar sesión25 minInput: tree = 7, left 3 (children 1 and 5), right 9 (left child 8)Output: chain 7 -> 3 -> 1 -> 5 -> 9 -> 8Empezar
- MediaVista superior de un árbol#bfs#column-indextiempo O(n)espacio O(n)Iniciar sesión25 minInput: tree = 8, left 4, whose left is 2Output: [2, 4, 8]Empezar
- MediaEl BST más grande dentro de un árbol#post-order#bsttiempo O(n)espacio O(h)Iniciar sesión30 minInput: tree = 5, left 3, right 8 (children 7 and 9)Output: 5Empezar
- MediaSerialización compacta de un BST#preorder#monotonic-stack#bsttiempo O(n)espacio O(n)Iniciar sesión30 minInput: tree = 8, left 3 (children 1 and 6), right 10 (right child 14)Output: encode -> "8 3 1 6 10 14"Empezar
- FácilReflejar un árbol binario#recursion#tree-traversaltiempo O(n)espacio 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]Empezar
- DifícilMayor suma de un camino entre nodos#post-order#tree-dp#global-besttiempo O(n)espacio O(h)Iniciar sesión35 minInput: tree = -10, left 9, right 20 (children 15 and 7)Output: 42Empezar
- FácilComprobar si el árbol está balanceado#post-order#early-exittiempo O(n)espacio O(h)15 minInput: tree = 3, left 9, right 20 (children 15 and 7)Output: TrueEmpezar
Tema · Tries
0 / 12 completados- MediaBúsqueda de palabras con comodín#trie#backtrackingtiempo O(26ᵈ · m)espacio O(total characters)Iniciar sesión30 minInput: words = ["bad", "dad", "mad"], query = ".ad"Output: TrueEmpezar
- MediaReemplazar palabras por sus raíces#trie#prefix-matchtiempo O(R + S)espacio O(R + S)Iniciar sesión25 minInput: roots = ["cat", "bat", "rat"], sentence = "the cattle was rattled by the battery"Output: "the cat was rat by the bat"Empezar
- DifícilPar con XOR máximo#bit-trie#greedytiempo O(n · b)espacio O(n · b)Iniciar sesión40 minInput: nums = [3, 10, 5, 25, 2, 8]Output: 28Empezar
- FácilOperaciones de un árbol de prefijos#trie#designtiempo O(L)espacio O(total characters)20 minInput: insert("apple"), has_word("apple"), has_word("app"), has_prefix("app")Output: True, False, TrueEmpezar
- MediaAutocompletado con tres sugerencias#trie#prefix-matchtiempo O(n log n + total characters)espacio O(total characters)Iniciar sesión30 minInput: products = ["mobile", "mouse", "moneypot", "monitor", "mousepad"], word = "mouse"Output: [["mobile", "moneypot", "monitor"],Empezar
- DifícilBúsqueda de palabras en una cuadrícula#trie#backtracking#grid-dfstiempo O(cells · 4 · 3^(L−1))espacio O(total word characters)Iniciar sesión45 minInput: grid = [["a"]], words = ["a", "aa"]Output: ["a"]Empezar
- MediaLa palabra más larga, letra a letra#trie#dfstiempo O(total characters)espacio O(total characters)Iniciar sesión25 minInput: words = ["w", "wo", "wor", "worl", "world"]Output: "world"Empezar
- FácilSuma de valores por prefijo#trie#designtiempo O(L)espacio O(total characters)20 minInput: put("apple", 3), total("ap"), put("app", 2), total("ap"), total("apple")Output: 3, 5, 3Empezar
- DifícilFin de palabra en un stream de letras#trie#reversed-trie#streamtiempo O(L)espacio O(total characters + L)Iniciar sesión40 minInput: words = ["cd", "f", "kl"], stream = "abcdefghijkl"Output: [F, F, F, T, F, T, F, F, F, F, F, T]Empezar
- MediaPrefijos únicos más cortos#trie#prefix-counttiempo O(L)espacio O(L)Iniciar sesión25 minInput: words = ["zebra", "dog", "duck", "dove"]Output: ["z", "dog", "du", "dov"]Empezar
- FácilPalabras del diccionario en un texto#trie#prefix-pruningtiempo O(n · L + W)espacio 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]]Empezar
- MediaCodificación más corta de palabras#trie#suffix-sharingtiempo O(W)espacio O(W)Iniciar sesión25 minInput: words = ["time", "me", "bell"]Output: 10Empezar
Tema · Heaps
0 / 14 completados- MediaEl k-ésimo valor más grande#min-heap#top-ktiempo O(n log k)espacio O(k)Iniciar sesión25 minInput: nums = [3, 2, 1, 5, 6, 4], k = 2Output: 5Empezar
- FácilChoque de las piedras más pesadas#max-heap#simulationtiempo O(n log n)espacio O(n)20 minInput: stones = [2, 7, 4, 1, 8, 1]Output: 1Empezar
- MediaPuntos más cercanos al origen#max-heap#top-ktiempo O(n log k)espacio O(k)Iniciar sesión30 minInput: points = [[3, 3], [5, -1], [-2, 4]], k = 2Output: [(3, 3), (-2, 4)]Empezar
- DifícilMediana en curso de un stream#two-heaps#streamingtiempo O(n log n)espacio O(n)Iniciar sesión45 minInput: stream = [5, 15, 1, 3]Output: [5.0, 10.0, 5.0, 4.0]Empezar
- MediaPlanificador de tareas con enfriamiento#heap#greedytiempo O(n log d + n · gap)espacio O(d)Iniciar sesión35 minInput: tasks = ["a", "a", "a", "b", "b", "b"], gap = 2Output: 8Empezar
- MediaReordenar un string sin vecinos iguales#heap#greedytiempo O(n log d)espacio O(n)Iniciar sesión30 minInput: s = "aab"Output: "aba"Empezar
- FácilComprobar si un array es un min-heap#heap#array-as-treetiempo O(n)espacio O(1)15 minInput: values = [1, 3, 2, 7, 4]Output: TrueEmpezar
- MediaOrdenar una lista casi ordenada#min-heap#k-sortedtiempo O(n log k)espacio O(n)Iniciar sesión25 minInput: nums = [3, 1, 2, 6, 4, 5], k = 2Output: [1, 2, 3, 4, 5, 6]Empezar
- MediaHasta dónde llegan ladrillos y escaleras#min-heap#greedytiempo O(n log ladders)espacio O(ladders)Iniciar sesión30 minInput: heights = [4, 2, 7, 6, 9, 14, 12], bricks = 5, ladders = 1Output: 4Empezar
- MediaProcesar tareas en una sola CPU#min-heap#event-simulationtiempo O(n log n)espacio O(n)Iniciar sesión30 minInput: tasks = [[1, 2], [2, 4], [3, 2], [4, 1]]Output: [0, 2, 3, 1]Empezar
- FácilLos k escuadrones más débiles#top-k#max-heaptiempo O(m · n + m log k)espacio 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]Empezar
- FácilLos k valores más cercanos a un objetivo#top-k#max-heaptiempo O(n log k)espacio O(k)15 minInput: nums = [9, 2, 14, 5, 7, 11], target = 8, k = 3Output: [5, 7, 9]Empezar
- FácilConvertir una lista en heap in-place#heapify#sift-downtiempo O(n)espacio O(1)15 minInput: nums = [5, 3, 8, 1, 2]Output: [1, 2, 8, 3, 5]Empezar
- MediaSeparar letras al menos k posiciones#max-heap#greedy#cooldown-queuetiempo O(n)espacio O(n)Iniciar sesión30 minInput: s = "aabbcc", k = 3Output: "abcabc"Empezar
Tema · Dos heaps y fusión de k listas
0 / 14 completados- MediaK-ésimo menor en una matriz#k-way-merge#heaptiempo O(n + k log n)espacio O(n)Iniciar sesión30 minInput: matrix = [[1, 5, 9], [10, 11, 13], [12, 13, 15]], k = 8Output: 13Empezar
- DifícilRango mínimo entre k listas#k-way-merge#sliding-windowtiempo O(n log k)espacio O(k)Iniciar sesión45 minInput: lists = [[4, 10, 15, 24, 26], [0, 9, 12, 20], [5, 18, 22, 30]]Output: [20, 24]Empezar
- DifícilElegir proyectos según el capital#two-heaps#greedytiempo O(n log n)espacio O(n)Iniciar sesión40 minInput: projects = [(0, 1), (1, 2), (2, 3)], capital = 0, rounds = 2Output: 3Empezar
- FácilFusionar k listas ordenadas#k-way-merge#min-heaptiempo O(n log k)espacio O(n)20 minInput: lists = [[1, 4, 5], [1, 3, 4], [2, 6]]Output: [1, 1, 2, 3, 4, 4, 5, 6]Empezar
- MediaLos k pares de menor suma#k-way-merge#min-heaptiempo O(k log k)espacio O(k)Iniciar sesión30 minInput: a = [1, 7, 11], b = [2, 4, 6], k = 3Output: [[1, 2], [1, 4], [1, 6]]Empezar
- DifícilMediana de una ventana deslizante#two-heaps#lazy-deletion#sliding-windowtiempo O(n log n)espacio O(n)Iniciar sesión45 minInput: nums = [1, 3, -1, -3, 5, 3, 6, 7], k = 3Output: [1.0, -1.0, -1.0, 3.0, 5.0, 6.0]Empezar
- MediaLos k valores más frecuentes#top-k#min-heap#hash-maptiempo O(n + d log k)espacio O(d)Iniciar sesión25 minInput: values = [4, 1, 4, 2, 1, 4, 3], k = 2Output: [4, 1]Empezar
- MediaSiguiente intervalo a la derecha#two-heaps#max-heaptiempo O(n log n)espacio O(n)Iniciar sesión30 minInput: spans = [[3, 4], [2, 3], [1, 2]]Output: [-1, 0, 1]Empezar
- MediaKth Smallest Prime Fraction#k-way-merge#min-heaptiempo O((n + k) log n)espacio O(n)Iniciar sesión30 minInput: values = [1, 2, 3, 5], k = 3Output: [2, 5]Empezar
- FácilPuntaje central tras cada entrada#two-heaps#streamingtiempo O(n log n)espacio O(n)20 minInput: scores = [5, 15, 1, 3]Output: [5, 5, 5, 3]Empezar
- FácilSpread compra-venta tras cada cotización#two-heaps#max-heap#min-heaptiempo O(n log n)espacio O(n)15 minInput: quotes = [("buy", 100), ("sell", 105), ("buy", 102), ("sell", 104), ("buy", 99)]Output: [None, 5, 3, 2, 2]Empezar
- MediaLas k palabras más frecuentes#top-k#min-heap#hash-maptiempo O(n + m log k)espacio O(m)Iniciar sesión20 minInput: words = ["red", "blue", "red", "green", "blue", "red"], k = 2Output: ["red", "blue"]Empezar
- FácilK-ésimo mayor en un stream de puntajes#min-heap#top-k#data-streamtiempo O(n log k)espacio O(k)15 minInput: k = 3, scores = [4, 5, 8, 2], then add 3, 5, 10, 9, 4Output: [4, 5, 5, 8, 8]Empezar
- DifícilNivelar cada ventana al menor costo#two-heaps#sliding-window#lazy-deletiontiempo O(n log n)espacio O(n)Iniciar sesión40 minInput: nums = [1, 3, 2, 8, 5, 5], k = 3Output: [2, 6, 6, 3]Empezar
Tema · Grafos
0 / 21 completados- MediaContar islas en una cuadrícula#dfs#flood-fill#grid-traversaltiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión30 minInput: [[1]]Output: 1Empezar
- MediaViabilidad del orden de cursos#topological-sort#cycle-detectiontiempo O(n + p)espacio O(n + p)Iniciar sesión35 minInput: n = 3, pairs = [[1, 0], [2, 1]]Output: TrueEmpezar
- DifícilWord Ladder: pasos mínimos#bfs#shortest-pathtiempo O(N · L² · 26)espacio O(N · L)Iniciar sesión45 minInput: start = hit, target = cog, words = [hot, dot, dog, lot, log, cog]Output: 5Empezar
- FácilEl juez de confianza del pueblo#degree-counting#directed-graphtiempo O(n + p)espacio O(n)15 minInput: n = 2, trust = [[1, 2]]Output: 2Empezar
- MediaCopia profunda de un grafo#dfs#hash-maptiempo O(V + E)espacio O(V)Iniciar sesión30 minInput: a square: 1 - 2 - 3 - 4 - 1Output: a new square with the same four labels and the same four linksEmpezar
- MediaMinutos hasta que todo se pudra#bfs#multi-source#grid-traversaltiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión30 minInput: [[0, 2]]Output: 0Empezar
- MediaComprobar una división en dos colores#bfs#graph-colouringtiempo O(V + E)espacio O(V)Iniciar sesión30 minInput: adj = [[1, 3], [0, 2], [1, 3], [0, 2]]Output: TrueEmpezar
- MediaTiempo de propagación de una señal#dijkstra#shortest-path#min-heaptiempo O((n + m) log m)espacio O(n + m)Iniciar sesión30 minInput: n = 3, links = [(0, 1, 4)], source = 0Output: -1Empezar
- MediaViaje más barato con límite de escalas#bellman-ford#shortest-pathtiempo O(k · (n + m))espacio O(n)Iniciar sesión35 minInput: n = 3, flights = [(0, 1, 5)], src = 0, dst = 2, k = 1Output: -1Empezar
- DifícilGrupos de alcance mutuo#strongly-connected-components#dfstiempo O(n log n + m)espacio O(n + m)Iniciar sesión45 minInput: n = 5, edges = [(0, 1), (1, 2), (2, 0), (2, 3), (3, 4)]Output: [[0, 1, 2], [3], [4]]Empezar
- DifícilCruzar con la marea creciente#union-find#minimum-spanning-tree#sortingtiempo O(rc log rc)espacio O(rc)Iniciar sesión45 minInput: heights = [[7]]Output: 7Empezar
- MediaNodos libres de ciclos#dfs#graph-colouring#cycle-detectiontiempo O(n + e)espacio O(n)Iniciar sesión30 minInput: graph = [[1, 2], [2], [3], [], [5], [4], [3, 4]]Output: [0, 1, 2, 3]Empezar
- FácilPares que se siguen mutuamente#adjacency-set#directed-graphtiempo O(n + m)espacio O(n + m)15 minInput: n = 4, follows = [[0, 1], [1, 0], [1, 2], [2, 3], [3, 2], [0, 2]]Output: 2Empezar
- DifícilAgua para todas las casas#prim#virtual-nodetiempo O((n + m) log(n + m))espacio O(n + m)Iniciar sesión40 minInput: wells = [3, 4, 2], pipes = [[1, 2, 1], [2, 3, 5]]Output: 6Empezar
- DifícilMínimo de carreteras para unir pueblos#strongly-connected-components#directed-graphtiempo O(n + r)espacio O(n + r)Iniciar sesión45 minInput: n = 5, roads = [(0, 1), (1, 2), (2, 0), (3, 2), (3, 4)]Output: 2Empezar
- FácilOrdenar los pasos del build#topological-sort#indegreetiempo O(n + m)espacio O(n + m)20 minInput: n = 4, deps = [[0, 1], [0, 2], [1, 3], [2, 3]]Output: [0, 1, 2, 3]Empezar
- FácilDeadlock en un grafo de espera#cycle-detection#graph-colouring#topological-sorttiempo O(n + m)espacio O(n + m)20 minInput: n = 4, waits = [[0, 1], [1, 2], [2, 0], [3, 0]]Output: TrueEmpezar
- FácilRuta más barata entre dos paradas#dijkstra#min-heaptiempo O((n + m) log n)espacio 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: 7Empezar
- FácilCaminos más cortos con reembolsos#bellman-ford#negative-edgestiempo O(n · m)espacio 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]Empezar
- DifícilOrden de un alfabeto alienígena#topological-sort#graph-from-constraintstiempo O(L)espacio O(len(words))Iniciar sesión40 minInput: words = ["wrt", "wrf", "er", "ett", "rftt"]Output: "wertf"Empezar
- FácilAbrir todas las habitaciones cerradas#dfs#reachabilitytiempo O(n + k)espacio O(n)15 minInput: rooms = [[1], [2], [3], []]Output: TrueEmpezar
Tema · Matrices y cuadrículas
0 / 14 completados- FácilPerímetro de una isla#grid-scan#neighbour-checktiempo O(rows · cols)espacio O(1)20 minInput: grid = [[1]]Output: 4Empezar
- MediaPoner en cero filas y columnas#grid-marking#in-placetiempo O(rows · cols)espacio O(rows + cols)Iniciar sesión25 minEmpezar
- MediaBuscar en una cuadrícula ordenada#staircase-walk#grid-searchtiempo O(rows + cols)espacio O(1)Iniciar sesión25 minInput: same grid, target = 10Output: NoneEmpezar
- FácilRepintar una región conexa#flood-fill#dfstiempo O(rows · cols)espacio O(rows · cols)15 minInput: grid = [[5]], row = 0, col = 0, colour = 3Output: [[3]]Empezar
- MediaRotar una cuadrícula cuadrada#in-place#transpose-reversetiempo O(n²)espacio O(1)Iniciar sesión20 minInput: grid = [[7]]Output: [[7]]Empezar
- DifícilCamino ascendente más largo#grid-dfs#memoizationtiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión40 minEmpezar
- MediaIslas interiores#flood-fill#grid-traversaltiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión30 minInput: grid = [[1]]Output: 0Empezar
- MediaCamino libre más corto en la cuadrícula#bfs#grid-traversal#shortest-pathtiempo O(rows · cols)espacio O(rows · cols)Iniciar sesión25 minInput: grid = [[0]]Output: 0Empezar
- DifícilMayor rectángulo de solo unos#monotonic-stack#grid-scantiempo O(rows · cols)espacio O(cols)Iniciar sesión45 minInput: grid = [[1, 1, 0, 1, 1, 1]]Output: 3Empezar
- FácilMismo valor en cada diagonal#matrix-indexing#diagonalstiempo O(rows · cols)espacio O(1)15 minInput: grid = [[1, 2, 3, 4], [5, 1, 2, 3], [9, 5, 1, 2]]Output: TrueEmpezar
- MediaSiguiente generación de celdas#eight-neighbours#in-place-encodingtiempo O(rows · cols)espacio O(1)Iniciar sesión25 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]]Empezar
- MediaCeldas que desaguan en ambas costas#reverse-flood-fill#multi-source-searchtiempo O(rows · cols · log(rows · cols))espacio O(rows · cols)Iniciar sesión30 minInput: heights = [[1, 2], [4, 3]]Output: [[0, 1], [1, 0], [1, 1]]Empezar
- FácilÁrea de la isla más grande#flood-fill#dfs#grid-traversaltiempo O(rows · cols)espacio O(rows · cols)15 minInput: grid = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 1], [0, 0, 1, 0]]Output: 4Empezar
- FácilLlenar una cuadrícula en espiral#matrix-traversal#direction-turningtiempo O(rows · cols)espacio O(rows · cols)15 minInput: rows = 3, cols = 3Output: [[1, 2, 3], [8, 9, 4], [7, 6, 5]]Empezar
Tema · Union-Find
0 / 12 completados- MediaContar provincias#union-find#connected-componentstiempo O(n² · α(n))espacio O(n)Iniciar sesión25 minInput: matrix = [[1, 1, 0], [1, 1, 0], [0, 0, 1]]Output: 2Empezar
- MediaRedundant Connection#union-find#cycle-detectiontiempo O(n · α(n))espacio O(n)Iniciar sesión25 minInput: edges = [[1, 2], [1, 3], [2, 3]]Output: [2, 3]Empezar
- DifícilFusión de cuentas por correo#union-find#hash-maptiempo O(E log E)espacio O(E)Iniciar sesión45 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"]]Empezar
- FácilComprobar si un par es alcanzable#union-find#connectivitytiempo O((n + m) · α(n))espacio O(n)15 minInput: n = 3, links = [[0, 1], [1, 2], [2, 0]], source = 0, target = 2Output: TrueEmpezar
- MediaIgualdades consistentes#union-find#two-phasetiempo O(n)espacio O(1)Iniciar sesión25 minInput: rules = ["a==b", "b!=a"]Output: FalseEmpezar
- MediaPiedras que comparten una línea#union-find#connected-componentstiempo O(n · α(n))espacio O(n)Iniciar sesión30 minInput: stones = [[0, 0], [0, 1], [1, 0], [1, 2], [2, 1], [2, 2]]Output: 5Empezar
- MediaPrimer momento con todo conectado#union-find#sort-by-timetiempo O(m log m + m · α(n))espacio O(n + m)Iniciar sesión25 minInput: n = 5, logs = [[20, 0, 1], [3, 3, 4], [5, 1, 2], [9, 2, 3], [12, 0, 3]]Output: 12Empezar
- MediaEl string equivalente más pequeño#union-find#stringstiempo O(n + m)espacio O(m)Iniciar sesión25 minInput: a = "parker", b = "morris", text = "parser"Output: "makkek"Empezar
- DifícilCarreteras de sobra para dos viajeros#union-find#greedytiempo O(m · α(n))espacio O(n)Iniciar sesión45 minInput: n = 4, roads = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4]]Output: 2Empezar
- DifícilEl grupo más grande por factor común#union-find#prime-factorstiempo O(n · √max(nums))espacio O(n)Iniciar sesión45 minInput: nums = [4, 6, 15, 35]Output: 4Empezar
- FácilLas aristas forman un solo árbol#union-find#cycle-detectiontiempo O(n · α(n))espacio O(n)15 minInput: n = 5, edges = [[0, 1], [0, 2], [0, 3], [1, 4]]Output: TrueEmpezar
- MediaIslas después de cada celda de tierra#union-find#online-connectivity#gridtiempo O(k · α(m · n))espacio O(k)Iniciar sesión30 minInput: m = 3, n = 3, positions = [[0, 0], [0, 1], [1, 2], [2, 1]]Output: [1, 1, 2, 3]Empezar
Tema · Intervalos
0 / 13 completados- MediaQuitar intervalos superpuestos#intervals#greedytiempo O(n log n)espacio O(n)Iniciar sesión25 minInput: intervals = [[1, 2], [2, 3], [3, 4], [1, 3]]Output: 1Empezar
- DifícilEmployee Free Time#intervals#mergetiempo O(n log n)espacio O(n)Iniciar sesión40 minInput: schedules = [[[1, 2], [5, 6]], [[1, 3]], [[4, 10]]]Output: [[3, 4]]Empezar
- MediaCapacidad del auto compartido#intervals#sweep-linetiempo O(n log n)espacio O(n)Iniciar sesión25 minInput: trips = [(2, 1, 5), (3, 3, 7)], capacity = 4Output: FalseEmpezar
- FácilAsistir a todas las reuniones#intervals#sortingtiempo O(n log n)espacio O(n)15 minInput: meetings = [[0, 30], [5, 10], [15, 20]]Output: FalseEmpezar
- FácilResumir valores en rangos#intervals#single-passtiempo O(n)espacio O(n)15 minInput: nums = [0, 1, 2, 4, 5, 7]Output: ["0->2", "4->5", "7"]Empezar
- MediaFusionar intervalos superpuestos#intervals#sorting#mergetiempo O(n log n)espacio O(n)Iniciar sesión20 minInput: spans = [[1, 3], [8, 10], [2, 6], [15, 18]]Output: [[1, 6], [8, 10], [15, 18]]Empezar
- MediaInsertar y fusionar un intervalo#intervals#mergetiempo O(n)espacio O(n)Iniciar sesión25 minInput: spans = [[1, 2], [4, 6], [9, 10]], new = [5, 9]Output: [[1, 2], [4, 10]]Empezar
- MediaIntersección de dos listas de intervalos#intervals#two-pointerstiempo O(m + n)espacio O(m + n)Iniciar sesión25 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]]Empezar
- MediaQuitar intervalos cubiertos por otros#intervals#sort-by-starttiempo O(n log n)espacio O(n)Iniciar sesión20 minInput: spans = [[1, 4], [3, 6], [2, 8]]Output: 2Empezar
- MediaCalendario sin reservas dobles#sorted-intervals#bisect-insert#half-open-intervalstiempo O(n)espacio O(n)Iniciar sesión25 minInput: book(10, 20), book(15, 25), book(20, 30)Output: [True, False, True]Empezar
- MediaMínimo de disparos para reventar globos#intervals#greedy#sort-by-endtiempo O(n log n)espacio O(n)Iniciar sesión25 minInput: balloons = [[10, 16], [2, 8], [1, 6], [7, 12]]Output: 2Empezar
- MediaSalas necesarias para las reuniones#min-heap#sweep-line#sortingtiempo O(n log n)espacio O(n)Iniciar sesión20 minInput: meetings = [(0, 30), (5, 10), (15, 20)]Output: 2Empezar
- FácilCortar un intervalo de otros ordenados#interval-overlap#single-passtiempo O(n)espacio O(n)15 minInput: spans = [[0, 2], [3, 4], [5, 7]], cut = [1, 6]Output: [[0, 1], [6, 7]]Empezar
Tema · Manipulación de bits
0 / 14 completados- FácilInvertir el orden de los bits#bit-shifting#accumulatortiempo O(1)espacio O(1)20 minInput: value = 1Output: 2147483648Empezar
- MediaEl valor solitario entre tríos#bit-counting#modular-arithmetictiempo O(n)espacio O(1)Iniciar sesión30 minInput: nums = [2, 2, 3, 2]Output: 3Empezar
- FácilEl valor que falta#xor-cancel#single-passtiempo O(n)espacio O(1)20 minInput: nums = [3, 0, 1]Output: 2Empezar
- FácilCantidad de bits distintos#xor#bit-countingtiempo O(log max(a, b))espacio O(1)15 minInput: a = 1, b = 4Output: 2Empezar
- FácilBits encendidos de cada número#bit-shifting#reuse-smaller-answertiempo O(n)espacio O(n)20 minInput: n = 5Output: [0, 1, 1, 2, 1, 2]Empezar
- MediaDos valores solitarios#xor-cancel#bit-partitiontiempo O(n)espacio O(1)Iniciar sesión30 minInput: nums = [1, 2, 1, 3, 2, 5]Output: [3, 5]Empezar
- FácilComprobar potencia de cuatro#bitmask#power-of-twotiempo O(1)espacio O(1)15 minInput: n = 16Output: TrueEmpezar
- FácilSubconjuntos con máscara de bits#bitmask#subsetstiempo O(n · 2ⁿ)espacio O(n · 2ⁿ)20 minInput: items = ["a", "b"]Output: [[], ['a'], ['b'], ['a', 'b']]Empezar
- MediaOrdenar con intercambios de bits iguales#popcount#adjacent-swapstiempo O(n log m)espacio O(1)Iniciar sesión25 minInput: nums = [6, 5, 3, 16, 8, 31]Output: TrueEmpezar
- DifícilRecorrido más corto por todos los nodos#bitmask#bfstiempo O(n² · 2ⁿ)espacio O(n · 2ⁿ)Iniciar sesión45 minInput: adj = [[1, 3, 4], [0, 2], [1, 3, 5], [2, 0], [0], [2]]Output: 6Empezar
- MediaSumar dos números sin el signo más#bitwise-add#carry-propagation#twos-complementtiempo O(1)espacio O(1)Iniciar sesión25 minInput: a = 1, b = 2Output: 3Empezar
- MediaAND a nivel de bits en un rango#common-prefix#bit-shifttiempo O(1)espacio O(1)Iniciar sesión20 minInput: lo = 5, hi = 7Output: 4Empezar
- MediaPares de palabras sin letras en común#bitmask#set-as-integertiempo O(L + n²)espacio O(n)Iniciar sesión20 minInput: words = ["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]Output: 16Empezar
- MediaSuma de diferencias de bits entre pares#bit-counting#per-bit-contributiontiempo O(n)espacio O(1)Iniciar sesión20 minInput: nums = [4, 14, 2]Output: 6Empezar
Tema · Matemáticas y teoría de números
0 / 13 completados- FácilCeros finales de un factorial#factor-counting#mathtiempo O(log n)espacio O(1)20 minInput: n = 5Output: 1Empezar
- MediaPrimos por debajo de un límite#sieve#precomputationtiempo O(n log log n)espacio O(n)Iniciar sesión25 minInput: limit = 10Output: 4Empezar
- MediaPotencia bajo un módulo#fast-exponentiation#modular-arithmetictiempo O(log exp)espacio O(1)Iniciar sesión25 minInput: base = 2, exp = 10, mod = 1000Output: 24Empezar
- FácilSuma de dígitos repetida#modular-arithmetic#mathtiempo O(1)espacio O(1)15 minInput: n = 38Output: 2Empezar
- MediaMedir con dos jarras#gcd#mathtiempo O(log min(a, b))espacio O(1)Iniciar sesión25 minInput: a = 3, b = 5, t = 4Output: TrueEmpezar
- MediaElegir k módulo un primo#combinatorics#modular-inversetiempo O(min(k, n − k) + log p)espacio O(1)Iniciar sesión30 minInput: n = 5, k = 2Output: 10Empezar
- FácilMínimo común múltiplo de una lista#gcd#lcmtiempo O(n log(max(nums)))espacio O(1)15 minInput: nums = [4, 6, 10]Output: 60Empezar
- MediaFracción como decimal periódico#long-division#hash-maptiempo O(den)espacio O(den)Iniciar sesión30 minInput: num = 1, den = 6Output: "0.1(6)"Empezar
- DifícilPrimos en un rango amplio#segmented-sieve#sievetiempo O((√hi + hi − lo) log log hi)espacio O(√hi + hi − lo)Iniciar sesión40 minInput: lo = 10, hi = 30Output: 6Empezar
- FácilUna fila del triángulo de Pascal#binomial-coefficients#multiplicative-formulatiempo O(k)espacio O(k)15 minInput: k = 3Output: [1, 3, 3, 1]Empezar
- FácilMáximo común divisor de strings#gcd#string-periodtiempo O(len(a) + len(b))espacio O(len(a) + len(b))15 minInput: a = "ABCABC", b = "ABC"Output: "ABC"Empezar
- MediaPares de canciones en minutos exactos#modular-arithmetic#remainder-counttiempo O(n)espacio O(1)Iniciar sesión20 minInput: times = [30, 20, 150, 100, 40]Output: 3Empezar
- MediaPotencia con un exponente enorme#fast-exponentiation#modular-arithmetictiempo O(len(b))espacio O(1)Iniciar sesión25 minInput: a = 2, b = [3]Output: 8Empezar
Tema · Programación dinámica
0 / 27 completados- FácilSubida de escalera más barata#bottom-up-dp#rolling-variablestiempo O(n)espacio O(1)20 minInput: cost = [10, 15, 20]Output: 15Empezar
- MediaCaminos en cuadrícula con bloqueos#grid-dp#bottom-up-dptiempo O(rows · cols)espacio O(cols)Iniciar sesión30 minInput: [[0]]Output: 1Empezar
- MediaSegmentación de oraciones#bottom-up-dp#hash-settiempo O(L³)espacio O(L)Iniciar sesión30 minInput: text = applepen, words = [apple, pen]Output: TrueEmpezar
- DifícilCompraventa con día de espera#state-machine-dp#rolling-variablestiempo O(n)espacio O(n)Iniciar sesión45 minInput: prices = [1, 2, 3, 0, 2]Output: 3Empezar
- FácilPintar casas al menor costo#bottom-up-dp#rolling-variablestiempo O(n)espacio O(1)20 minInput: costs = [[7, 6, 2]]Output: 2Empezar
- MediaDecodificar un mensaje de dígitos#bottom-up-dp#rolling-variablestiempo O(n)espacio O(1)Iniciar sesión30 minInput: digits = "226"Output: 3Empezar
- MediaFormas distintas de BST#bottom-up-dp#countingtiempo O(n²)espacio O(n)Iniciar sesión30 minInput: n = 3Output: 5Empezar
- DifícilReventar globos por monedas#interval-dp#bottom-up-dptiempo O(n³)espacio O(n²)Iniciar sesión50 minInput: values = [3, 1, 5, 8]Output: 167Empezar
- FácilCosecha sin parcelas vecinas#bottom-up-dp#rolling-variablestiempo O(n)espacio O(1)20 minInput: yields = [2, 7, 9, 3, 1]Output: 12Empezar
- MediaMínimo de monedas para un monto#bottom-up-dp#unbounded-knapsacktiempo O(amount · len(coins))espacio O(amount)Iniciar sesión30 minInput: coins = [1, 4, 6], amount = 8Output: 2Empezar
- MediaSubsecuencia ascendente más larga#bottom-up-dp#subsequence-dptiempo O(n²)espacio O(n)Iniciar sesión30 minInput: nums = [4, 1, 3, 2, 5, 3, 6]Output: 4Empezar
- MediaMenos ediciones entre palabras#string-dp#bottom-up-dptiempo O(len(a) · len(b))espacio O(len(b))Iniciar sesión35 minInput: a = "carpet", b = "parrot"Output: 3Empezar
- DifícilSobres anidados#binary-search#patience-sorting#sortingtiempo O(n log n)espacio O(n)Iniciar sesión45 minInput: envelopes = [[4, 5], [4, 6], [6, 7], [2, 3], [1, 1]]Output: 4Empezar
- DifícilCortar una vara al menor costo#interval-dp#bottom-up-dptiempo O(m³)espacio O(m²)Iniciar sesión50 minInput: length = 10, marks = [2, 4, 7]Output: 20Empezar
- MediaFormas de pagar un monto#unbounded-knapsack#bottom-up-dptiempo O(k · amount)espacio O(amount)Iniciar sesión25 minInput: coins = [2, 3, 5], amount = 10Output: 4Empezar
- DifícilConstruir la supersecuencia más corta#string-dp#subsequence-dptiempo O(len(a) · len(b))espacio O(len(a) · len(b))Iniciar sesión45 minInput: a = "tile", b = "style"Output: "stiyle"Empezar
- MediaLongest Palindromic Subsequence#lcs#2d-dptiempo O(n²)espacio O(n)Iniciar sesión30 minInput: s = "character"Output: 5Empezar
- MediaSignos que alcanzan un objetivo#0-1-knapsack#subset-counttiempo O(n · sum(nums))espacio O(sum(nums))Iniciar sesión30 minInput: nums = [1, 2, 3, 4], target = 2Output: 2Empezar
- DifícilMínimo de vigilantes en un árbol#tree-dp#state-machinetiempo O(n)espacio O(h)Iniciar sesión45 minInput: tree = 1, left 2, whose children are 3 and 4Output: 1Empezar
- DifícilPorciones de pastel con dos amigos#circular-dp#exact-count-dptiempo O(n²)espacio O(n)Iniciar sesión45 minInput: slices = [4, 1, 2, 8, 3, 5]Output: 13Empezar
- MediaCarga más valiosa para una camioneta#unbounded-knapsack#bottom-up-dptiempo O(W · len(crates))espacio O(W)Iniciar sesión25 minInput: W = 10, crates (weight, value) = [(3, 5), (4, 7), (6, 11)]Output: 18Empezar
- MediaDivisión más pareja en dos equipos#0-1-knapsack#subset-sumtiempo O(n · sum(ratings))espacio O(sum(ratings))Iniciar sesión30 minInput: ratings = [5, 8, 13, 2]Output: 2Empezar
- FácilTarjetas de regalo para un total exacto#0-1-knapsack#subset-sumtiempo O(n · total)espacio O(total)20 minInput: cards = [3, 34, 4, 12, 5, 2], total = 9Output: TrueEmpezar
- FácilCambio exacto con monedas ilimitadas#unbounded-knapsack#bottom-up-dptiempo O(len(coins) · amount)espacio O(amount)15 minInput: coins = [4, 7], amount = 15Output: TrueEmpezar
- FácilCamino más barato por una cuadrícula#grid-dp#2d-dptiempo O(rows · cols)espacio O(rows · cols)20 minInput: grid = [[1, 3, 1], [1, 5, 1], [4, 2, 1]]Output: 7Empezar
- FácilMenos borrados para igualar dos palabras#lcs#string-dptiempo O(m · n)espacio O(m · n)20 minInput: a = "sea", b = "eat"Output: 2Empezar
- MediaIntercalar dos strings#two-string-dp#rolling-rowtiempo O(len(a) · len(b))espacio O(len(b))Iniciar sesión30 minInput: a = "aabcc", b = "dbbca", c = "aadbbcbcac"Output: TrueEmpezar
Tema · Diseño de sistemas
0 / 8 completados- FácilRate limiter con token bucket#token-bucket#integer-mathtiempo O(n)espacio O(n)15 minInput: capacity = 2, per_second = 1, times_ms = [0, 0, 0, 500, 1000, 3000]Output: [True, True, False, False, True, True]Empezar
- FácilQuórum de lectura según el de escritura#quorum#pigeonholetiempo O(1)espacio O(1)10 minInput: n = 3, w = 2Output: (2, 1)Empezar
- MediaAnillo de hashing consistente#consistent-hashing#virtual-nodes#bisecttiempo O(log p)espacio O(p)Iniciar sesión25 minInput: nodes = db-a, db-b, db-c; owner("user:42") before and after db-d joinsOutput: db-c db-cEmpezar
- MediaDimensionar un filtro de Bloom#bloom-filter#double-hashingtiempo O(k)espacio O(m)Iniciar sesión25 minInput: n = 1000, p = 0.01Output: (9586, 7)Empezar
- MediaBalanceador por menos conexiones#least-connections#min-heap#event-simulationtiempo O(n (log n + s))espacio O(n + s)Iniciar sesión25 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})Empezar
- FácilPercentiles de latencia por nearest rank#percentiles#sortingtiempo O(n log n + q)espacio 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}Empezar
- MediaTiempo de espera de visibilidad en colas#message-queue#event-simulationtiempo O(p · m)espacio O(p + m)Iniciar sesión25 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'])Empezar
- MediaCamino crítico a través de una traza#distributed-tracing#interval-union#tree-walktiempo O(n log n)espacio O(n)Iniciar sesión25 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'])Empezar
Tema · Casos de diseño de sistemas
0 / 4 completados- FácilCapacidad de un acortador de URL#capacity-estimation#back-of-the-envelopetiempo O(log(total links))espacio 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}Empezar
- MediaCosto del fan-out de un feed#fan-out#cost-modeltiempo O(E + U)espacio O(E + U)Iniciar sesión25 minInput: the same graph and posts, but only ann opens the feed, once a dayOutput: ({'push': 93, 'pull': 4, 'hybrid': 14}, 'pull')Empezar
- MediaLímites por plan en un API Gateway#rate-limiting#sliding-window-logtiempo O(r log n)espacio O(n)Iniciar sesión25 minInput: tiers = {"free": [(10, 1)]}, requests from "a" at 0, 9, 10, 19, 20Output: {'a': [3, 2]}Empezar
- FácilTasa de aciertos de caché de un feed#lru-cache#hit-ratiotiempo O(n)espacio O(c)15 minInput: feed = ["a", "b", "c", "a", "b", "c"], capacity = 2Output: 0.0Empezar
Tema · IA y ML
0 / 8 completados- FácilSoftmax con temperatura#softmax#numerical-stabilitytiempo O(v)espacio O(v)15 minInput: logits = [2.0, 1.0, 0.1], temperature = 1.0Output: [0.659, 0.242, 0.099]Empezar
- FácilPresupuesto de memoria de la caché KV#capacity-math#memory-estimatetiempo O(1)espacio O(1)10 minInput: layers = 32, kv_heads = 32, head_dim = 128, tokens = 4096, batch = 1, 2 bytes per numberOutput: 2048.0Empezar
- MediaDocumentos más cercanos por coseno#vector-math#partial-sorttiempo O(n · d + n log k)espacio O(n)Iniciar sesión20 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)]Empezar
- MediaAjustar un chat a la ventana de contexto#token-budget#newest-firsttiempo O(t)espacio O(1)Iniciar sesión20 minInput: budget = 100, system = 20, reserve = 25, turns = [10, 30, 10, 20, 15]Output: 2Empezar
- DifícilAprender fusiones de pares de bytes#byte-pair-encoding#pair-countingtiempo O(m · L)espacio O(L)Iniciar sesión35 minInput: words = {"low": 5, "lower": 2, "newest": 6, "widest": 3}, merges = 4Output: [('e', 's'), ('es', 't'), ('l', 'o'), ('lo', 'w')]Empezar
- FácilIda y vuelta de cuantización int8#quantization#scale-and-roundtiempo O(n)espacio O(n)15 minInput: [0.4, -2.54, 0.013, 1.0]Output: ([20, -127, 1, 50], 0.02, 0.007)Empezar
- MediaPasadas en decodificación especulativa#speculative-decoding#draft-and-verifytiempo O(n · k)espacio O(n)Iniciar sesión25 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)Empezar
- DifícilRecall de un índice de archivo invertido#vector-search#inverted-file-index#recall-at-ktiempo O(n · c + c · q · n log n)espacio O(n + c)Iniciar sesión35 minInput: the same vectors and centroids, queries = [(6, 1)], k = 2Output: [0.5, 1.0, 1.0]Empezar
Tema · Diseño de bajo nivel
0 / 8 completados- FácilCalculadora de cobro de estacionamiento#class-design#pricing-rules15 minInput: same lot, fee("car", 26 * 60)Output: 26Empezar
- FácilMáquina expendedora con monedas#class-design#state-machine15 minInput: then insert(100), select("A1"), select("A1")Output: ['credit 125', 'vend A1, change 60', 'sold out']Empezar
- MediaCaché LRU con expiración#ordered-dict#lazy-expiry#min-heaptiempo O(log n)espacio O(number of puts)Iniciar sesión30 minInput: then get("a", now=10)Output: NoneEmpezar
- MediaBus de eventos con comodines en topics#observer#topic-matchingtiempo O(s · d)espacio O(s · d)Iniciar sesión25 minInput: then unsubscribe(the audit token), publish("order.created", "o8")Output: 0Empezar
- DifícilSistema de archivos en memoria#class-design#path-walk#invariantsIniciar sesión35 minInput: then read("/logs/app/today.txt"), size("/")Output: 'boot ok\nuser in\n' 23Empezar
- FácilMejor estrategia de descuento al pagar#strategy-pattern#class-designtiempo O(p · c)espacio O(1)15 minInput: cart = [("coffee", 1200, 3), ("mug", 900, 2)], all three promotionsOutput: ('buy 2 coffee get 1 free', 4200)Empezar
- MediaParadas del ascensor en orden de barrido#elevator-sweep#event-simulationtiempo O(F · p + r log r)espacio O(r)Iniciar sesión25 minInput: start = 3, requests = [(0, 5), (0, 1), (1, 4), (6, 2)]Output: [(1, 4), (2, 5), (6, 1), (7, 2)]Empezar
- DifícilJugadas legales que protegen al rey#board-model#move-generation#check-detectiontiempo O(P² · 27²)espacio O(P)Iniciar sesión35 minInput: {"h8": "k", "g7": "Q", "f6": "K"}, black to moveOutput: ('checkmate', [])Empezar
Tema · Concurrencia
0 / 8 completados- FácilActualizaciones perdidas en un contador#race-condition#step-simulationtiempo O(s)espacio O(t)15 minInput: threads = 2, schedule = [0, 0, 0, 1, 1, 1]Output: 2Empezar
- FácilTamaño del pool de hilos para una carga#capacity-math#integer-ceilingtiempo O(1)espacio O(1)10 minInput: cores = 8, utilization = 100, wait_ms = 90, compute_ms = 10Output: 80Empezar
- MediaHilos en deadlock en un grafo de espera#wait-for-graph#cycle-detectiontiempo O(t + l)espacio O(t)Iniciar sesión25 minInput: holds = {"a": "T1", "b": "T2"}, waits = {"T1": "b", "T2": "a"}Output: ['T1', 'T2']Empezar
- MediaTiempos de inicio tras un semáforo#min-heap#event-simulationtiempo O(n log p)espacio O(n)Iniciar sesión20 minInput: permits = 2, jobs = [(0, 5), (1, 3), (2, 4), (3, 1)]Output: [0, 1, 4, 5]Empezar
- DifícilEntregas en un buffer acotado#bounded-queue#event-simulation#fifo-fairnesstiempo O(n)espacio O(n)Iniciar sesión35 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')], [])Empezar
- FácilReintentos en un bucle compare-and-swap#compare-and-swap#step-simulationtiempo O(s)espacio O(t)15 minInput: start = 0, amounts = [5, 7], schedule = [0, 1, 0, 1, 1, 1]Output: (12, [0, 1])Empezar
- MediaFin de cada tarea en un solo event loop#event-loop#min-heap#event-simulationtiempo O(s log n)espacio O(n)Iniciar sesión25 minInput: [("api", 0, [2, 10, 1]), ("report", 1, [30]), ("ping", 3, [1])]Output: {'report': 32, 'ping': 33, 'api': 34}Empezar
- MediaOrden de locks que evita el deadlock#lock-ordering#topological-sort#min-heaptiempo O(E + L log L)espacio O(E + L)Iniciar sesión25 minInput: [["accounts", "ledger"], ["ledger", "audit"], ["accounts", "audit"]]Output: ['accounts', 'ledger', 'audit']Empezar
Tema · SQL
0 / 15 completados- FácilSegundo salario más alto#scalar-subquery#aggregate10 minInput: employee = [(1, "Ana", 300), (2, "Ben", 200), (3, "Cy", 100)]Output: [(200,)]Empezar
- FácilCorreos usados más de una 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)]Empezar
- FácilClientes que nunca hicieron un pedido#left-join#anti-join15 minEmpezar
- FácilGanan más que su manager#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)]Empezar
- MediaDepartamento con mayor salario promedio#group-by#cte#tiesIniciar sesión20 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)]Empezar
- MediaDos mejores salarios por departamento#window-function#top-n-per-groupIniciar sesión25 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)]Empezar
- MediaLibros por autor en una sola consulta#n-plus-one#left-join#group-byIniciar sesión20 minEmpezar
- MediaSaldo acumulado por cuenta#window-function#running-total#window-frameIniciar sesión25 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),Empezar
- MediaInició sesión tres días seguidos#window-function#consecutive-rows#dedupeIniciar sesión25 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",)]Empezar
- DifícilCompactar un log de estados en tramos#gaps-and-islands#window-function#row-numberIniciar sesión35 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)]Empezar
- MediaLa misma lectura tres veces seguidas#self-join#consecutive-rows#distinctIniciar sesión20 minInput: reading = [(1, 1), (2, 1), (3, 1), (4, 2), (5, 1), (6, 2), (7, 2)]Output: [(1,)]Empezar
- MediaEl mejor pagado de cada departamento#correlated-subquery#max#tiesIniciar sesión20 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)]Empezar
- MediaClientes que compraron todo el catálogo#group-by#having#count-distinctIniciar sesión20 minInput: product = [5, 6], purchase = [(1, 5), (2, 6), (3, 5), (3, 6), (1, 6)]Output: [(1,), (3,)]Empezar
- DifícilUsuarios retenidos mes a mes#cte#self-join#retentionIniciar sesión35 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)]Empezar
- FácilVentas trimestrales como columnas#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)]Empezar