Problem Solving — fill the blank — 336 questions
Play ▸- #1 · Fill the Python keyword that defines a function. ____ greet(name): return "Hi " + name
- #2 · Fill the built-in that yields the numbers 0..9. for i in ____(10): print(i)
- #3 · Fill the slice step that reverses a Python list. reversed_list = nums[::____]
- #4 · Fill the dict method that returns a default when the key is missing. count = freq.____("a", 0)
- #5 · Fill the list method that adds x to the end. stack.____(x) # push onto the stack
- #6 · Fill the method that removes and returns the last item. top = stack.____() # LIFO remove
- #7 · Fill the operator for integer (floor) division. mid = (lo + hi) ____ 2 # binary search
- #8 · Fill the operator that tests membership in a set. if target - x ____ seen: # Two Sum
- #9 · Fill the operator that compares n with 0. if n ____ 0: return 1 # factorial base case
- #10 · Fill the operator to add n to the recursive result. def rec(n): if n == 0: return 0 return n ____ rec(
- #11 · Fill the function name in binary search's Big-O. # binary search runs in big_o = "O(____ n)"
- #12 · Fill to complete the Pythonic swap of a and b. a, b = b, ____ # swap a and b
- #13 · Fill the list method that sorts in place. nums.____() # ascending, in place
- #14 · Fill the built-in that removes duplicates. unique = ____(items) # remove duplicates
- #15 · Fill the built-in that returns how many elements a list has. n = ____(arr) # number of elements
- #16 · Fill to advance the left pointer by 1. while total > k: left ____ 1 # shrink the window
- #17 · Fill the keyword that returns mid. if arr[mid] == target: ____ mid
- #18 · Fill the set method that adds node. visited.____(node) # mark as seen (a set)
- #19 · Fill the heapq function that pushes x onto heap h. import heapq heapq.____(h, x) # push x
- #20 · Fill the operator for remainder (modulo). if n ____ 2 == 0: # even?
- #21 · Fill the keyword so it reads 'if not visited'. if ____ visited[node]: dfs(node) # if not visited
- #22 · Fill the step so the loop visits every 2nd index. for i in range(0, n, ____): # every 2nd index
- #23 · Fill the str method that joins a list with commas. csv = ",".____(parts) # join with commas
- #24 · Fill the built-in that returns the smallest value. smallest = ____(nums)
- #25 · Fill the built-in that returns the largest value. largest = ____(nums)
- #26 · Fill the operator so each x is squared (x to the power 2). squares = [x____2 for x in range(n)]
- #27 · Fill the comparison so x becomes |a|. x = a if a ____ 0 else -a # absolute value
- #28 · Fill the operator so the loop runs while left is before right. while left ____ right: # two pointers
- #29 · Fill the operator to check the stack is empty. return len(stack) ____ 0 # is it empty?
- #30 · Fill to add 1 to count. count ____ 1 # increment the counter
- #31 · Fill the operator that repeats the list n+1 times. dp = [0] ____ (n + 1) # n+1 zeros
- #32 · Fill the bitwise operator that clears the lowest set bit. x = x ____ (x - 1) # clear lowest set bit
- #33 · Fill the keyword that exits a loop early. if found: ____ # stop the loop early
- #34 · Fill the comparison for the Fibonacci base case (n = 0 or 1). def fib(n): if n ____ 2: return n return fib(n-1)
- #35 · Fill the built-in that returns how many items are in a list. nums = [1, 2, 3] print(____(nums))
- #36 · Fill the string method that returns an uppercase copy. s = "hello" print(s.____()) # HELLO
- #37 · Fill the list method that adds an item to the end (push). stack = [] stack.____(5) # push
- #38 · Fill the dict method that returns a default when the key is missing. d = {} value = d.____("k", 0)
- #39 · Fill the operator for integer (floor) division of the midpoint. lo, hi = 0, len(a) - 1 mid = (lo + hi) ____ 2
- #40 · Fill the operator that multiplies n by the recursive result. def fact(n): if n == 0: return 1 return n ____ fac
- #41 · Fill the function name in the binary-search time complexity. # Binary search runs in O(____ n) time
- #42 · Fill the built-in that yields 0..4 in a for loop. for i in ____(5): print(i)
- #43 · Fill the list method that sorts in place ascending. arr = [3, 1, 2] arr.____() # [1, 2, 3]
- #44 · Fill the type that stores unique items with add(). seen = ____() seen.add(x)
- #45 · Fill the double-ended queue used for BFS. from collections import deque q = ____()
- #46 · Fill the math function that returns the square root. import math print(math.____(16)) # 4.0
- #47 · Fill the bitwise operator that isolates the lowest bit. # true when n is even if n ____ 1 == 0:
- #48 · Fill the cache name checked before recomputing. if n in ____: return memo[n]
- #49 · Fill the string method that breaks text on spaces. words = sentence.____(" ")
- #50 · Fill the deque method that removes from the left. q = deque([1, 2, 3]) q.____() # removes 1
- #51 · Fill the expression that completes an in-place swap. arr[i], arr[j] = arr[j], ____
- #52 · Fill the step that reverses a list via slicing. rev = lst[::____]
- #53 · Fill the operator combining the two recursive Fibonacci calls. def fib(n): if n < 2: return n return fib(n - 1) _
- #54 · Fill the complexity of accessing an array element by index. # Array index access is O(____)
- #55 · Fill in the complexity of binary search. # Binary search on a sorted array is O(log ____)
- #56 · Fill in merge sort's worst-case complexity. # Merge sort worst case is O(n log ____)
- #57 · Fill in the average lookup cost of a hash table. # Average hash-table lookup is O(____)
- #58 · Fill in the amortized cost of an append. # Appending to a dynamic array is amortized O(____
- #59 · Fill in the FIFO data structure. # A ____ is a first-in, first-out collection
- #60 · Fill in the LIFO data structure. # A ____ is a last-in, first-out collection
- #61 · Fill in the tree name. # A binary ____ tree keeps left < node < right
- #62 · Fill in the structure name. # A hash ____ maps keys to values via a hash funct
- #63 · Fill in the in-place list method. nums.____() # reverse the list in place
- #64 · Fill in the key function. words.sort(key=____) # sort by word length
- #65 · Fill in the built-in that applies a function to every item. list(____(str, [1, 2, 3])) # -> ['1', '2', '3']
- #66 · Fill in the collections class. from collections import ____ # dict with automatic
- #67 · Fill in the dict method that returns a default. count = d.____(key, 0) # read with a fallback
- #68 · Fill in the slice step that reverses a string. reversed_text = s[::____] # reverse a string
- #69 · Fill in the string method. parts = 'a-b-c'.____('-') # -> ['a', 'b', 'c']
- #70 · Fill in the method that joins a list into a string. line = '-'.____(['a', 'b']) # -> 'a-b'
- #71 · Fill in the term. # A word that reads the same both ways is a ____
- #72 · Fill in the recursive step. def fact(n): return 1 if n <= 1 else n * fact(n -
- #73 · Fill in the term. # The base ____ is what stops a recursive function
- #74 · Fill in the search name. # ____ search requires the input to be sorted
- #75 · Fill in the sort name. # ____ sort repeatedly picks the smallest remainin
- #76 · Fill in the complexity. # Two pointers on a sorted array find a pair in O(
- #77 · Fill in the traversal (abbreviation is fine). # ____ explores a graph level by level using a que
- #78 · Fill in the traversal (abbreviation is fine). # ____ goes as deep as possible before backtrackin
- #79 · Fill in the algorithm's name. # ____'s algorithm finds shortest paths with non-n
- #80 · Fill in the technique. # Caching subproblem results is called ____
- #81 · Fill in the constant. x & (x - ____) # clears the lowest set bit
- #82 · Fill in the operator. doubled = n ____ 1 # multiply by two with a shift
- #83 · Fill in the operator. # Euclid: gcd(a, b) == gcd(b, a ____ b)
- #84 · Fill in the pattern name. # The ____ pattern allows only one instance of a c
- #85 · Fill the blank to complete the function // returns the sum of a and b function add(a, b) {
- #86 · What goes in the blank? # returns the number of items in the list def coun
- #87 · Complete the function // returns true if n is even function isEven(n) {
- #88 · Fill in the blank # adds 5 to the end of the list nums nums = [1, 2,
- #89 · What goes in the blank? // returns the first character of the string s fun
- #90 · Complete the loop // prints 0, 1, 2, 3, 4 for (let i = 0; i ____ 5;
- #91 · Fill the blank // returns the string in all uppercase function sh
- #92 · What goes in the blank? // returns the length of the array arr function si
- #93 · Complete the function // returns the larger of a and b function bigger(a
- #94 · Fill in the blank // returns the value doubled const double = (n: nu
- #95 · What goes in the blank? // returns true only if both conditions are true f
- #96 · Complete the function # returns the value of name from the dict person p
- #97 · Fill the blank // returns the absolute value of n function abs(n)
- #98 · What goes in the blank? // returns a new array with each number doubled fu
- #99 · Complete the function # returns only the even numbers from nums def even
- #100 · Fill in the blank // returns the array reversed without mutating fun
- #101 · What goes in the blank? # removes and returns the last element of the list
- #102 · Complete the function // returns true if the array contains the value fu
- #103 · Fill the blank # joins the list of words into one space-separated
- #104 · What goes in the blank? // returns the value, or "default" if value is fal
- #105 · Complete the function // returns "yes" if n is positive, otherwise "no"
- #106 · Fill in the blank # returns a list of numbers 0,1,2,3,4 def first_fi
- #107 · What goes in the blank? // returns the string with leading/trailing spaces
- #108 · Complete the function // returns the sum of all numbers in nums function
- #109 · Fill the blank // returns a greeting using the provided name, def
- #110 · What goes in the blank? // returns only numbers greater than 10 function b
- #111 · Complete the function // returns the first number greater than 10, or un
- #112 · What goes in the blank? # returns index and value pairs while looping def
- #113 · Fill in the blank // returns a copy of the first 2 elements function
- #114 · Complete the comprehension # returns a dict mapping each word to its length d
- #115 · What goes in the blank? // returns true only if every number is positive f
- #116 · Fill the blank # returns the count of each character in s def fre
- #117 · Complete the function // returns nums sorted in ascending numeric order
- #118 · What goes in the blank? // returns the index of "x", or -1 if not present
- #119 · Fill in the blank # returns the list with duplicates removed (order
- #120 · Complete the recursion // returns n! (factorial) recursively function fac
- #121 · What goes in the blank? // returns the keys of the object as an array func
- #122 · Fill the blank # returns elements of a that are also in b def com
- #123 · Complete the function // returns a flattened one-level array function fl
- #124 · What goes in the blank? # returns the most common element in items from co
- #125 · Fill in the blank // returns a memoized version of fn function memoi
- #126 · Complete the recursion // returns the nth Fibonacci number (fib(0)=0, fib
- #127 · What goes in the blank? // returns an object grouping words by first lette
- #128 · Fill the blank # returns a list of (key, value) sorted by value d
- #129 · Complete the function // returns the sum of values using reduce with a t
- #130 · What goes in the blank? // returns a debounced function that delays calls
- #131 · Fill in the blank # returns a generator yielding squares of nums def
- #132 · Complete the function // returns the deduplicated array preserving order
- #133 · What goes in the blank? # returns pairs of corresponding elements from a a
- #134 · Fill the blank // returns a promise that resolves after ms millis
- #135 · What goes in the blank? # split a sentence into words words = "a b c".____
- #136 · What goes in the blank? # total of a list of numbers total = ____(nums)
- #137 · What goes in the blank? # smallest value in the list lowest = ____(nums)
- #138 · Complete the function # does the name start with "Mr"? flag = name.____(
- #139 · Fill in the blank # drop surrounding whitespace clean = raw.____()
- #140 · Fill the blank # swap every comma for a space out = text.____(","
- #141 · What goes in the blank? // add an item to the end const list = [1, 2]; lis
- #142 · What goes in the blank? // remove and return the FIRST item const first =
- #143 · Fill in the blank // is ANY score above 90? const high = scores.____
- #144 · What goes in the blank? # True when EVERY value is positive ok = ____(v >
- #145 · Fill the blank # True when AT LEAST ONE value is negative bad = _
- #146 · What goes in the blank? // sum the array into one value const total = nums
- #147 · Complete the loop # walk the dictionary as key/value pairs for k, v
- #148 · Fill in the blank # longest word first words.sort(____=len, reverse=
- #149 · What goes in the blank? # sort pairs by the second field pairs.sort(key=__
- #150 · Fill the blank # guard: only numbers allowed if not ____(v, (int,
- #151 · What goes in the blank? # add every item of another list base.____(extra)
- #152 · Fill in the blank // map then flatten one level const tags = posts._
- #153 · What goes in the blank? // always two digits: "7" -> "07" const mm = Strin
- #154 · Fill the blank // a divider line of 20 dashes const line = '-'.__
- #155 · What goes in the blank? // remove 2 items starting at index 1 list.____(1,
- #156 · Fill in the blank # how many times does 'a' appear? n = letters.____
- #157 · What goes in the blank? // parse a JSON string into an object const cfg =
- #158 · Fill the blank // run no matter what happened above try { save();
- #159 · Complete the comprehension # {'a': 1, 'b': 2} -> {1: 'a', 2: 'b'} flipped = {
- #160 · Complete the function # yield a running total def running(nums): t = 0 f
- #161 · What goes in the blank? // wait for every request together const all = awa
- #162 · Fill in the blank // first one to settle wins const fastest = await
- #163 · What goes in the blank? # count each word in one line from collections imp
- #164 · Fill the blank // narrow away null before using it if (v ____ nul
- #165 · What goes in the blank? # "ana" -> "Ana" name = raw.____()
- #166 · Fill in the blank # "HELLO" -> "hello" q = text.____()
- #167 · What goes in the blank? # "7" -> "007" code = num.____(3, "0")
- #168 · Complete the function # does the file end in .csv? ok = path.____(".csv"
- #169 · Fill the blank # add a key only if it is missing cfg.____("port",
- #170 · What goes in the blank? # merge another dict into this one base.____(extra
- #171 · Complete the loop # walk the list from last to first for x in ____(i
- #172 · Fill in the blank # stop with a clear error if v < 0: ____ ValueErro
- #173 · What goes in the blank? // add an item to the FRONT queue.____('first');
- #174 · Fill the blank // position of the LAST match const i = list.____(
- #175 · What goes in the blank? // index of the first match, or -1 const i = rows.
- #176 · Fill in the blank // object -> [[key, value], ...] const pairs = Obj
- #177 · What goes in the blank? // [[k, v], ...] -> object const obj = Object.____
- #178 · Fill the blank // object -> array of its values const vals = Obje
- #179 · What goes in the blank? // object -> JSON text const body = JSON.____(payl
- #180 · Complete the function // block the default form submit form.addEventList
- #181 · Fill in the blank // stop the event reaching the parent child.addEve
- #182 · What goes in the blank? // is it an array? if (Array.____(v)) { walk(v); }
- #183 · Fill the blank // class check for a Date if (d ____ Date) { fmt(d
- #184 · What goes in the blank? // make the method keep its object const bound = o
- #185 · Fill in the blank // keep only the truthy values const clean = rows.
- #186 · What goes in the blank? // wait, then continue await new Promise((r) => __
- #187 · Fill the blank // read the id written in the markup const id = el
- #188 · What goes in the blank? // toggle a css class safely el.____.toggle('activ
- #189 · Fill in the blank # every value that is in BOTH sets both = a.____(b
- #190 · What goes in the blank? # values in a but NOT in b only = a.____(b)
- #191 · Fill the blank # remove if present, ignore if not tags.____("old"
- #192 · What goes in the blank? # group values under a key, no KeyError from colle
- #193 · Fill in the blank # pull the next item from an iterator first = ____
- #194 · What goes in the blank? # 3.7 -> 3 (toward zero) n = ____(3.7)
- #195 · Fill the blank # reuse the file handle safely ____ open(path) as
- #196 · Complete the loop # skip this row and keep looping for r in rows: if
- #197 · What goes in the blank? # call the parent constructor class Admin(User): d
- #198 · Complete the function # the constructor of a class class Point: def ____
- #199 · Fill in the blank // inherit from a base class class Admin ____ User
- #200 · What goes in the blank? // a method callable without an instance class Mat
- #201 · Fill the blank // signal a failure to the caller if (!ok) { ____
- #202 · What goes in the blank? // collect the remaining arguments function log(fi
- #203 · Fill in the blank // read a nested value without crashing const city
- #204 · What goes in the blank? // keep 0 but default null/undefined const n = inp
- #205 · Fill the blank // wait for all, keep failures too const res = awa
- #206 · What goes in the blank? // a key that cannot collide const hidden = ____('
- #207 · Complete the function // produce values lazily function* ids() { let i =
- #208 · Fill in the blank # a lightweight immutable record from typing impor
- #209 · What goes in the blank? # rebind a name from the enclosing function def ou
- #210 · Fill the blank # expose a computed attribute class Box: @____ def
- #211 · What goes in the blank? # generate a data class with __init__ for free fro
- #212 · Fill in the blank // a value that may be absent let name: string | _
- #213 · What goes in the blank? // every field optional, none required type Draft
- #214 · Fill the blank // nothing may be reassigned type Frozen = ____<Co
- #215 · What goes in the blank? # print each item on its own line for item in item
- #216 · What goes in the blank? # add x to the end of the list nums.____(x)
- #217 · What goes in the blank? # uppercase copy of the name shout = name.____()
- #218 · What goes in the blank? # remove and return the last item last = stack.___
- #219 · What goes in the blank? # sort by the second element of each pair pairs.so
- #220 · What goes in the blank? # build a dict from a list of (key, value) pairs l
- #221 · What goes in the blank? # read the whole file into one string text = f.___
- #222 · What goes in the blank? # pair each element of a with the matching one in
- #223 · What goes in the blank? # get the index alongside the value for i, value i
- #224 · What goes in the blank? # count how often each word appears counts = ____(
- #225 · What goes in the blank? // add one to every number const bumped = nums.___
- #226 · What goes in the blank? // keep only the positive numbers const positive =
- #227 · What goes in the blank? // index of the final element const last = arr[arr
- #228 · What goes in the blank? // total of every number in the array const total
- #229 · What goes in the blank? // pause until the promise settles const data = __
- #230 · What goes in the blank? // true only when every item passes const allOk =
- #231 · What goes in the blank? // the first matching user, or undefined const hit
- #232 · What goes in the blank? // clone a plain object through JSON const copy =
- #233 · Fill the blank // every property becomes optional type Draft = __
- #234 · Fill the blank // keep only the listed keys type Summary = ____<U
- #235 · Fill the blank // everything except the listed keys type Safe = _
- #236 · What goes in the blank? # break a sentence into a list of words words = se
- #237 · What goes in the blank? # glue the words back together with single spaces
- #238 · What goes in the blank? // strip whitespace from both ends const clean = r
- #239 · What goes in the blank? # does the filename end with .txt? ok = name.____(
- #240 · What goes in the blank? // take the first element off the front const head
- #241 · What goes in the blank? # collapse the list down to unique values unique =
- #242 · What goes in the blank? # a queue with O(1) pops from the left frontier =
- #243 · What goes in the blank? # always pop the smallest item first smallest = he
- #244 · What goes in the blank? # midpoint of a binary search window mid = (low +
- #245 · What goes in the blank? # swap two elements in place arr[i], arr[j] = arr[
- #246 · What goes in the blank? # discard the half that cannot contain the target
- #247 · What goes in the blank? def fact(n): if n <= 1: return 1 return n * ____(n
- #248 · What goes in the blank? def fib(n, memo={}): if n in ____: return memo[n]
- #249 · Fill the blank # one pass over n items # time complexity: O(____)
- #250 · Fill the blank # a loop over n inside a loop over n # time comple
- #251 · What goes in the blank? # true when the lowest bit is set is_odd = n ____
- #252 · What goes in the blank? # keep only the unique values unique = ____(items)
- #253 · What goes in the blank? # pair each item with its index for i, item in ___
- #254 · What goes in the blank? # walk two lists together for a, b in ____(xs, ys)
- #255 · What goes in the blank? # read a key, defaulting when absent value = confi
- #256 · What goes in the blank? // sum every number in the array const total = num
- #257 · What goes in the blank? // true when any item matches const hasAdmin = use
- #258 · What goes in the blank? // first matching element, not its index const fou
- #259 · What goes in the blank? # capitalise the first letter of each word heading
- #260 · What goes in the blank? # add to the end of a Python list queue.____(item)
- #261 · What goes in the blank? from collections import defaultdict groups = ____(
- #262 · What goes in both blanks? from collections import ____ freq = ____(text) pri
- #263 · What goes in the blank? # sort by the second field, descending rows.sort(k
- #264 · What goes in the blank? // wait for all of them, keeping order const resul
- #265 · What goes in the blank? // flatten one level of nesting const flat = pairs
- #266 · What goes in the blank? // copy own enumerable props onto target Object.__
- #267 · What goes in the blank? # halve the search space each step mid = (lo + hi)
- #268 · What goes in the blank? import heapq # smallest element first heapq.____(h
- #269 · What goes in the blank? from collections import deque q = deque() # take f
- #270 · What goes in both blanks? from functools import ____ @____(maxsize=None) def
- #271 · What goes in the blank? # build one string from a list line = ', '.____(pa
- #272 · What goes in the blank? # shortest path on an unweighted graph frontier =
- #273 · What goes in the blank? # clear the lowest set bit x = x ____ (x - 1)
- #274 · What goes in the blank? # T(n) = 2T(n/2) + O(n) # solves to O(n ____ n)
- #275 · What goes in the blank? # 0/1 knapsack, one row reused for w in range(cap,
- #276 · What goes in the blank? # longest window with no repeats while seen[ch] >
- #277 · What goes in the blank? // last element, without changing the array const
- #278 · What goes in the blank? # count the vowels in a word n = sum(1 for ch in w
- #279 · What goes in the blank? import math # pages needed for n items, 10 per pag
- #280 · What goes in the blank? // random whole number from 0 to 5 const r = Math.
- #281 · What goes in the blank? # last item of a Python list last = items[____]
- #282 · What goes in the blank? # sum of the digits of n total = 0 while n > 0: to
- #283 · What goes in the blank? # Gregorian leap year rule leap = y % 4 == 0 and (
- #284 · What goes in the blank? // clamp n into the range [lo, hi] const c = Math.
- #285 · What goes in the blank? # are a and b anagrams? ok = ____(a) == sorted(b)
- #286 · What goes in the blank? # store an undirected edge (u, v) graph[u].append(
- #287 · What goes in the blank? def is_prime(n): i = 2 while i * i ____ n: if n %
- #288 · What goes in the blank? // count words with a Map const counts = new Map<s
- #289 · What goes in the blank? # flip bit k of x x = x ____ (1 << k)
- #290 · What goes in the blank? # fewest coins for every amount up to target dp =
- #291 · What goes in the blank? # Dijkstra: relax edge u -> v of weight w if d + w
- #292 · What goes in the blank? # union-find with path compression def find(x): if
- #293 · What goes in the blank? # heapify: sift down from the last parent to the r
- #294 · What goes in the blank? // longest common subsequence table dp[i][j] = a[i
- #295 · What goes in the blank? # Kadane: best sum of a contiguous subarray best =
- #296 · What goes in the blank? # Kahn's topological sort for v in graph[u]: indeg
- #297 · What goes in the blank? // true for "", " " and "\t" (Java 11+) boolean bl
- #298 · What goes in the blank? // Go: grow the slice by one element xs = ____(xs,
- #299 · What goes in the blank? // 3.14159 -> "3.14" const label = x.____(2);
- #300 · What goes in the blank? import math # whole-number square root: 17 -> 4 r
- #301 · What goes in the blank? import math # greatest common divisor: (12, 18) ->
- #302 · What goes in the blank? # number of 1 bits: 13 (0b1101) -> 3 ones = n.____
- #303 · What goes in the blank? // Java: sort the array in place, ascending int[]
- #304 · What goes in the blank? // Go: runs only when key k is present in m if _,
- #305 · What goes in the blank? # keep only the digits: 'a1b2' -> '12' digits = ''
- #306 · What goes in the blank? // deep copy that keeps Dates and Maps intact cons
- #307 · What goes in the blank? # 4-way neighbours of grid cell (r, c) for dr, dc
- #308 · What goes in the blank? # ways to climb n steps, 1 or 2 at a time def ways
- #309 · What goes in the blank? # insert at the FRONT of a Python list of n items
- #310 · What goes in the blank? # all subsets: each item is either left out or tak
- #311 · What goes in the blank? // Java: midpoint that cannot overflow int int mid
- #312 · What goes in the blank? # isolate the lowest set bit: 12 (0b1100) -> 4 low
- #313 · What goes in the blank? # directed cycle check: GRAY = still on the DFS pa
- #314 · What goes in the blank? # length of the longest STRICTLY increasing subseq
- #315 · What goes in the blank? # sliding-window maximum: keep a deque of indexes
- #316 · What goes in the blank? # fast modular power: square the base, halve the e
- #317 · What goes in the blank? import math # least common multiple: (4, 6) -> 12
- #318 · What goes in the blank? # prefix sums: prefix[i] = sum of nums[:i] prefix
- #319 · What goes in the blank? # trie as nested dicts: insert one word node = roo
- #320 · What goes in the blank? # palindrome check with mirrored indexes n = len(s
- #321 · What goes in the blank? # is n a power of two? (one bit set) ok = n > 0 an
- #322 · What goes in the blank? # lower_bound: first index with a[i] >= x lo, hi =
- #323 · What goes in the blank? # sieve of Eratosthenes, prime i found for j in ra
- #324 · What goes in the blank? # Floyd cycle detection on a linked list slow = fa
- #325 · What goes in the blank? # BFS shortest path in an unweighted graph for v i
- #326 · What goes in the blank? # next greater element with a monotonic stack of i
- #327 · What goes in the blank? # stable merge step of merge sort if left[i] ____
- #328 · What goes in the blank? from collections import OrderedDict # LRU cache: m
- #329 · What goes in the blank? # permutations by backtracking for x in choices: i
- #330 · What goes in the blank? # Fenwick tree prefix sum of [1..i] s = 0 while i
- #331 · What goes in the blank? # KMP failure table: fail[i] = longest proper pref
- #332 · What goes in the blank? import random # reservoir sampling: keep k items f
- #333 · What goes in the blank? # bitmask DP (travelling salesman): visit city v n
- #334 · What goes in the blank? # recursive segment tree over n leaves (root = 1,
- #335 · What goes in the blank? # modular inverse when m is prime (Fermat) inv = p
- #336 · What goes in the blank? # quickselect: k-th smallest, p = pivot's final in