InterviewDB Experience

AI-Assisted Code Review Assessment - Coding Interview

Interview Experience

Problem

An AI tool flags potentially buggy code regions as (file, start_line, end_line, confidence) where confidence is 0.0-1.0. Human reviewers have capacity to manually review at most B total lines. Select a subset of flagged regions to maximize total confidence score, subject to:
1. Total lines reviewed <= B.
2. No two selected regions from the same file may overlap.

python
def select_regions(
    flags: list[tuple[str, int, int, float]],  # (file, start, end, confidence)
    budget: int
) -> list[tuple[str, int, int, float]]:
    ...

Example:

flags = [
  ("a.py", 1, 10, 0.9),
  ("a.py", 5, 15, 0.8),  # overlaps with first
  ("b.py", 1, 5,  0.7),
]
budget = 15
Output: [("a.py",1,10,0.9), ("b.py",1,5,0.7)]  # total lines=15, score=1.6

Follow-ups
- How do you handle the per-file overlap constraint? Is it still a standard knapsack after removing overlaps?
- What is the time complexity of your approach?
- Extend to support a minimum confidence threshold: only consider regions with confidence >= 0.5.

Full Details

Problem

An AI tool flags potentially buggy code regions as (file, start_line, end_line, confidence) where confidence is 0.0-1.0. Human reviewers have capacity to manually review at most B total lines. Select a subset of flagged regions to maximize total confidence score, subject to:
1. Total lines reviewed <= B.
2. No two selected regions from the same file may overlap.

python
def select_regions(
    flags: list[tuple[str, int, int, float]],  # (file, start, end, confidence)
    budget: int
) -> list[tuple[str, int, int, float]]:
    ...

Example:

flags = [
  ("a.py", 1, 10, 0.9),
  ("a.py", 5, 15, 0.8),  # overlaps with first
  ("b.py", 1, 5,  0.7),
]
budget = 15
Output: [("a.py",1,10,0.9), ("b.py",1,5,0.7)]  # total lines=15, score=1.6

Follow-ups
- How do you handle the per-file overlap constraint? Is it still a standard knapsack after removing overlaps?
- What is the time complexity of your approach?
- Extend to support a minimum confidence threshold: only consider regions with confidence >= 0.5.

About This Question

This is a candidate experience report from a codesignal interview.

It covers the following topics: Dynamic Programming, Ai-Assisted, Sql, Coding .