← KKR Interview Insights

KKR·Software Engineer·Online Assessment (OA)·Junior

JuniorPending
Jun 2026

Summary

Did the KKR on-campus OA recently. 15 MCQs plus 3 DSA problems, and the DSA side was pretty manageable if you've done any leetcode prep at all.

Questions Asked (3)

Q1

Find the maximum length of a subarray (window) containing only unique elements.

Algorithms & Data Structures
Author's notes

Sliding window with a set, pretty textbook.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use the sliding window technique with a hash map to track the last seen index of each character. Expand the right pointer, and when a duplicate is found, move the left pointer to the maximum of its current position and the last seen index + 1. Keep track of the maximum window length throughout.

Pro tip: Clarify whether the input is a string or an array, and discuss the trade-offs between using a fixed-size array (for ASCII) versus a hash map (for Unicode) to demonstrate attention to constraints and optimization.

1. Clarify the problem

Ask about the input type (string, array), character set (ASCII, Unicode), and whether the subarray must be contiguous. Confirm that we need the length, not the actual subarray.

2. Choose the right data structure

Decide between a hash map (general) or an array (if character set is small and known) to store the last seen index of each element. Explain your choice based on constraints.

3. Implement sliding window

Initialize left and right pointers at 0, and max_length at 0. Iterate right from 0 to n-1. If the current element is in the map and its last seen index >= left, update left to last_seen + 1. Update the map with the current index. Update max_length.

4. Analyze complexity

State that time complexity is O(n) because each element is visited at most twice (by right and left pointers). Space complexity is O(min(n, m)) where m is the size of the character set.

5. Test with examples

Walk through a simple example (e.g., 'abcabcbb') and an edge case (empty input, all unique, all duplicates) to verify correctness and handle boundaries.

Key Points to Mention

  • Sliding window technique with two pointers
  • Hash map to store last seen index of each character
  • Time complexity O(n) and space complexity O(min(n, m))
  • Handling duplicates by moving left pointer to last seen index + 1
  • Edge cases: empty input, all unique, all same characters
  • Comparison with brute force O(n^2) approach to highlight efficiency

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

Q2

Course Scheduler: given a list of courses with prerequisites, determine if all courses can be completed.

Algorithms & Data Structures
Author's notes

Classic cycle detection on a directed graph.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the courses and prerequisites as a directed graph, then check for cycles using either Kahn's algorithm (BFS-based topological sort) or DFS with recursion stack. If a cycle exists, not all courses can be completed; otherwise, they can.

Pro tip: Clarify edge cases upfront (e.g., duplicate prerequisites, self-loops, disconnected graphs) and mention that the problem reduces to cycle detection in a directed graph. This shows you think about robustness and can save time during implementation.

1. Clarify the problem

Ask about input format (e.g., number of courses, list of prerequisite pairs), constraints (e.g., course labels, possible duplicates), and expected output (boolean). Confirm that prerequisites form a directed edge from prerequisite to course.

2. Model as a graph

Represent courses as nodes and prerequisites as directed edges. Build an adjacency list and optionally an in-degree array for Kahn's algorithm.

3. Choose cycle detection method

Decide between Kahn's algorithm (BFS topological sort) or DFS with recursion stack. Explain the trade-offs: Kahn's is iterative and easy to reason about; DFS can be more concise but requires careful state tracking.

4. Implement and test

Write clean code for the chosen method, handling edge cases like empty input, no prerequisites, and disconnected components. Walk through a small example to verify correctness.

5. Analyze complexity

State time and space complexity: O(V + E) time and O(V + E) space, where V is number of courses and E is number of prerequisite pairs.

Key Points to Mention

  • Graph representation: adjacency list and in-degree array (for Kahn's) or visited/recursion stack (for DFS).
  • Cycle detection: a cycle means at least one course cannot be completed.
  • Topological sort: if all nodes are processed, no cycle exists.
  • Time and space complexity: O(V + E) for both approaches.
  • Edge cases: empty input, no prerequisites, self-loops, duplicate edges, disconnected graphs.
  • Trade-offs: Kahn's algorithm is iterative and avoids recursion depth issues; DFS can be simpler but may hit stack limits for large graphs.

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

Q3

Find the minimum ship capacity needed to carry all packages within a given number of days.

Algorithms & Data Structures
Author's notes

Binary search on the answer.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as a classic 'minimize the maximum' problem that can be solved with binary search on the answer. Define the search space between the maximum package weight and the total sum of all packages, then for each candidate capacity, simulate the shipping process to check if it's feasible within the given days. Return the smallest feasible capacity.

Pro tip: Always clarify edge cases upfront, such as when the number of days is less than the number of packages (impossible) or when a single package exceeds the capacity. Also, mention that the simulation can be optimized by greedily loading packages in order, which is optimal for this problem.

1. Understand the problem and constraints

Restate the problem: given an array of package weights and a number of days, find the minimum ship capacity to ship all packages within that many days. Clarify that packages must be shipped in order and cannot be split.

2. Identify the binary search approach

Explain that the answer lies between the maximum single package weight (lower bound) and the sum of all weights (upper bound). Use binary search to efficiently find the minimum capacity.

3. Design the feasibility check

Write a helper function that, given a capacity, simulates shipping by greedily adding packages to the current day's load until adding the next would exceed capacity, then incrementing the day count. Return whether the total days needed is <= the given days.

4. Implement binary search

Perform binary search on the capacity range, updating the bounds based on the feasibility check. When the search converges, return the lower bound as the minimum capacity.

5. Analyze complexity and edge cases

State that the time complexity is O(n log(sum - max)) and space is O(1). Discuss edge cases like days < number of packages (impossible) or days >= number of packages (capacity = max weight).

Key Points to Mention

  • Binary search on the answer space (capacity) rather than on the array.
  • Lower bound = max(package weights), upper bound = sum(package weights).
  • Greedy simulation for feasibility check: load packages in order until capacity exceeded.
  • Time complexity: O(n log(sum - max)) where n is number of packages.
  • Edge cases: days < n (impossible), days >= n (answer = max weight).
  • The problem is equivalent to 'split array largest sum' or 'capacity to ship packages within D days'.

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