← nebius Interview Insights

nebius·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Jul 2026

Summary

Four coding problems back to back for a Nebius SWE round. Nothing too exotic but the problems had enough edge cases to keep you honest. Felt like a solid algorithmic screen.

Questions Asked (4)

Q1

You are given daily health-check results for a set of microservices. A day counts as healthy only if every single microservice passed that day. Find the longest streak of consecutive healthy days.

Algorithms & Data Structures
Author's notes

Sliding window or just a linear scan works fine here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the input format (e.g., a 2D boolean matrix of days × services) and define a healthy day as one where all services pass. Then iterate through the days, maintaining a running streak count that resets to zero on any unhealthy day, and track the maximum streak seen.

Pro tip: Mention that you can optimize by short-circuiting the check for each day (stop at the first failed service) and that the solution is O(D × S) time and O(1) extra space, which is optimal since you must inspect every cell in the worst case.

1. Clarify input and constraints

Ask about the data representation (e.g., list of lists, CSV) and edge cases like empty input or all healthy days. Confirm that a day is healthy only if every service passes.

2. Define the algorithm

Explain that you will scan days sequentially, compute whether each day is healthy, and update the current and maximum streak lengths accordingly.

3. Walk through an example

Use a small example (e.g., 3 services, 5 days) to demonstrate how the streak resets on an unhealthy day and how the maximum is tracked.

4. Analyze complexity

State that the time complexity is O(D × S) where D is the number of days and S is the number of services, and space complexity is O(1) beyond the input.

5. Discuss edge cases and optimizations

Mention handling of empty input, all unhealthy days, and the possibility of short-circuiting the per-day check to avoid unnecessary evaluations.

Key Points to Mention

  • Definition of a healthy day: all services must pass.
  • Single-pass iteration with a running streak counter.
  • Resetting the streak to zero when an unhealthy day is encountered.
  • Tracking the maximum streak length seen so far.
  • Time complexity O(D × S) and space complexity O(1).
  • Edge cases: empty input, all healthy, all unhealthy, single day/service.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given a string, find the length of the shortest substring that contains every distinct character present in the full string at least once.

Algorithms & Data Structures
Author's notes

Sliding window again.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem and edge cases, then propose an efficient sliding window approach that expands and contracts to find the shortest substring containing all distinct characters. Explain the algorithm step-by-step, analyze its time and space complexity, and optionally discuss alternative methods like binary search with sliding window.

Pro tip: Demonstrate strong communication by walking through a concrete example (e.g., 'aabcbcdbca') to illustrate how the window adjusts, and mention that the sliding window approach is optimal because it processes each character at most twice, achieving O(n) time.

1. Clarify requirements and edge cases

Confirm that the substring must be contiguous and contain every distinct character from the original string at least once. Discuss edge cases: empty string, single character, all characters distinct, and repeated characters.

2. Outline the sliding window strategy

Use two pointers (left and right) to represent a window. Expand right to include characters until all distinct characters are covered, then shrink left to minimize the window while maintaining coverage.

3. Detail the algorithm with data structures

Maintain a frequency map (or array) for characters in the current window and a counter for how many distinct characters are fully covered. Update the minimum length whenever the window is valid.

4. Analyze complexity and correctness

Explain that each character is added and removed at most once, giving O(n) time and O(k) space where k is the number of distinct characters. Argue correctness by invariant: the window always contains all distinct characters when valid.

5. Discuss alternatives and trade-offs

Mention that a brute-force approach is O(n^2) and inefficient. Optionally, describe a binary search on substring length combined with a sliding window check, which also runs in O(n log n) but is less optimal than the two-pointer method.

Key Points to Mention

  • Sliding window technique with two pointers
  • Frequency map or array to track character counts
  • Counter for distinct characters fully covered
  • Time complexity O(n) and space complexity O(k)
  • Edge cases: empty string, all distinct characters, repeated characters
  • Comparison with brute-force and binary search approaches

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Given a list of product IDs and an integer m, you can delete exactly m individual occurrences. What's the minimum number of distinct product IDs that can remain after all deletions?

Algorithms & Data Structures
Author's notes

Greedy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem: we have a list of product IDs (with possible duplicates) and must delete exactly m individual occurrences to minimize the number of distinct IDs remaining. The optimal strategy is to delete all occurrences of the least frequent IDs first, because removing a distinct ID entirely reduces the distinct count by 1 at the lowest cost. Sort the frequency counts ascending, then greedily delete entire groups while the cumulative frequency does not exceed m; if m remains after removing some groups, the remaining distinct count is the answer.

Pro tip: Always confirm edge cases with the interviewer: what if m is larger than the total number of occurrences? What if m equals the total? Also, mention that the greedy choice is optimal because deleting a less frequent ID always costs fewer deletions per distinct ID removed.

1. Clarify the problem

Restate the problem to ensure understanding: we have a list of product IDs (with duplicates) and an integer m. We must delete exactly m individual occurrences to minimize the number of distinct IDs remaining. Confirm that we can delete any occurrences, not necessarily entire groups.

2. Count frequencies

Compute the frequency of each distinct product ID. This gives a list of counts representing how many occurrences each ID has.

3. Sort frequencies

Sort the frequency counts in ascending order. This allows us to consider removing the least frequent IDs first, which is optimal for minimizing distinct count.

4. Greedily remove entire groups

Iterate through the sorted frequencies. For each frequency f, if m >= f, subtract f from m and reduce the distinct count by 1 (i.e., remove that ID entirely). If m < f, stop; we cannot remove another entire ID without exceeding m deletions.

5. Return the remaining distinct count

After the loop, the number of distinct IDs left is the answer. If m becomes 0 exactly after removing some groups, the remaining distinct count is the answer. If m is still positive but less than the next frequency, we cannot reduce the distinct count further.

Key Points to Mention

  • Greedy strategy: remove least frequent IDs first to minimize distinct count per deletion.
  • Sorting frequencies ascending is key to the greedy approach.
  • Time complexity: O(n + k log k) where n is total occurrences and k is number of distinct IDs.
  • Space complexity: O(k) for frequency map and sorted list.
  • Edge cases: m >= total occurrences (answer 0), m = 0 (answer = original distinct count), and m exactly equals sum of some smallest frequencies.
  • Proof of optimality: any solution that removes a more frequent ID before a less frequent one can be improved by swapping, so greedy is optimal.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Given an array of strings, count how many pairs (i, j) with i < j can have their characters combined and rearranged to form a palindrome.

Algorithms & Data Structures
Author's notes

A string can form a palindrome if at most one character has an odd frequency.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that two strings can form a palindrome if and only if their combined character counts have at most one odd frequency. Then, represent each string by a bitmask of odd-count characters and count pairs whose masks differ by at most one bit (including identical masks). Use a hash map to count mask frequencies and compute the number of valid pairs efficiently.

Pro tip: Mention that the bitmask approach works because there are only 26 lowercase letters, so the mask fits in an integer; this shows you consider constraints and optimize accordingly. Also, explicitly handle the case where masks are identical, as that is a common oversight.

1. Clarify the palindrome condition

Explain that a string can be rearranged into a palindrome if and only if at most one character has an odd count. For two strings combined, this means the XOR of their odd-count masks has at most one bit set.

2. Encode each string as a bitmask

For each string, compute a 26-bit integer where each bit represents the parity (odd/even) of the count of a letter. This mask captures the essential information for palindrome formation.

3. Count pairs with compatible masks

Use a hash map to store the frequency of each mask. For each mask, count pairs with identical masks and with masks that differ by exactly one bit (i.e., mask XOR (1<<k) for each k). Sum these counts.

4. Analyze complexity and edge cases

State that the time complexity is O(n * 26) and space O(n). Discuss edge cases like empty strings, strings with all even counts, and large input sizes.

Key Points to Mention

  • Palindrome condition: at most one character with odd frequency.
  • Bitmask representation: 26 bits for lowercase English letters.
  • XOR operation to combine masks: result must have at most one bit set.
  • Hash map to count mask frequencies and compute pairs.
  • Time complexity O(n * 26) and space O(n).
  • Edge cases: empty strings, strings with all even counts, and duplicate masks.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.