Zalando Coding Interview Questions (Reported) 10 questions in 5 chapters

  1. 01String, array and interval problems3 questions
  2. 02Greedy and graph problems3 questions
  3. 03Practical coding and algorithm design3 questions
  4. 04Patterns and how to solve them
  5. 05Sources

String, array and interval problems

Contact search, two-digit sums, and the length of a union of intervals.

  • 1.1 How do you find a contact by a partial phone number? Easy 3 min

    I scan each saved phone number and keep the name when the typed digits appear as a contiguous substring. If several contacts match, I return the lexicographically smallest name, and if none match I return NO CONTACT. A TreeSet or a single running minimum both work. The test is a substring, not a subsequence, so 436800143 contains 6800 but not 3614. Time is linear in the total length of the numbers.

    Read the full answer
  • 1.2 How do you sum the two-digit integers in an array? Easy 2 min

    I walk the array once and add every integer whose absolute value is between 10 and 99 inclusive. That includes negatives, so 2, 5, minus 66 and 23 sum to minus 43. Single-digit values, numbers with three or more digits, and zero are skipped. The work is linear time and constant extra space. A check that only tests whether n is greater than 9 and less than 100 would drop the negative two-digit values.

    Read the full answer
  • 1.3 How do you compute the time covered by a set of intervals? Medium 3 min

    The examples match the length of the union of the intervals, measuring each interval as end minus start. I sort by start, merge overlaps into a running span, and add the length of each finished span. Touching endpoints such as one-two and two-three form one span of length two. Sorting plus a single merge pass is n log n time. The original report did not define open versus closed ends; this reading is inferred from the two worked examples.

    Read the full answer

Greedy and graph problems

Change-making, constrained string construction, and flood fill.

  • 2.1 Can you give change for every customer in an ice-cream queue? Easy 3 min

    The ice cream costs five euros and I start with no notes, so a ten or a twenty can be served only if I already hold the right change. I count fives and tens as I go. A ten needs one five. A twenty should first try a ten and a five, otherwise three fives. The queues 5, 5, 5, 10, 20 and 5, 5, 10 succeed; 10, 10 and 10, 5 fail. Time is linear.

    Read the full answer
  • 2.2 How do you build the longest string from AA, BB and AB without three in a row? Medium 3 min

    Each block has length two, so the longest string uses as many blocks as possible without three As or three Bs in a row. AA may be followed only by BB; BB and AB may be followed by AA or AB. I use every AB, then alternate AA and BB, taking all of the scarcer one and at most one extra of the other. Two AA, one BB and one AB become ABAABBAA.

    Read the full answer
  • 2.3 How does flood fill work, and how do you implement it? Medium 3 min

    Flood fill recolors the four-connected region that shares the starting cell's color. I record the old color, and if it already equals the new color I stop, otherwise I run BFS or DFS from the start and repaint every reachable cell of that old color. The work is linear in the number of cells. A former Zalando interviewer used this problem, taken from Cracking the Coding Interview; the usual statement is the same as LeetCode Flood Fill.

    Read the full answer

Practical coding and algorithm design

Autosuggest with debounce, merge sort in little extra memory, and Dijkstra.

  • 3.1 How would you implement a search box that suggests results on every keystroke? Medium 3 min

    The reported task is a search box that fetches suggestions on every keystroke. The important parts are a complete happy path, tests, clear names, and not calling the backend on every key. I debounce the input so a request goes out only after the user pauses, and I ignore stale responses so a slow earlier query cannot overwrite a later one. A short cache and a minimum query length are the usual next optimizations.

    Read the full answer
  • 3.2 How do you explain merge sort, and can it run in constant extra space? Medium 4 min

    Standard merge sort splits the array, sorts each half, and merges them into a buffer. That is n log n time and n extra space, plus a logarithmic call stack. The running time is not logarithmic; only the recursion depth is. You can merge in constant extra space by sliding elements in place, but that merge is quadratic, so the sort slows down. Heapsort is the usual n log n alternative with constant extra memory.

    Read the full answer
  • 3.3 How does Dijkstra's shortest-path algorithm work? Medium 3 min

    Dijkstra finds shortest paths from one source in a graph with non-negative edge weights. I keep a distance array, start the source at zero, and repeatedly settle the unsettled node with the smallest distance, relaxing its outgoing edges. With a binary heap the time is on the order of E plus V times log V. Negative edges are not allowed; those need Bellman-Ford. Unweighted graphs can use a plain breadth-first search instead.

    Read the full answer

Patterns and how to solve them

Problem types, difficulty, and how to work under a time limit or with tests.

  • 4.1 What coding patterns show up in reported Zalando problems, and how should you solve them? Medium 5 min

    The reported algorithmic problems sit in the Easy to Medium band: strings, hash maps, two pointers, binary search, greedy simulation, interval union, and light graph work such as flood fill. Later rounds also want you to clarify the prompt, write tests, and keep a small design simple. I restate the rules and edge cases, ship a correct solution, then tighten time and memory. Hidden tests punish missed edges, so I try empty input, no match, and the failure cases.

    Read the full answer

Sources