PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency with version control diffs, repository library APIs, file I/O and CSV parsing, and data aggregation to map changed files to their owners.

  • medium
  • Stripe
  • Coding & Algorithms
  • Software Engineer

Assign Reviewers from Changed Files

Company: Stripe

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Write a Java program that helps automatically assign a code reviewer after a pull request is opened. You are given: 1. A local Git repository path. 2. Two branch names: `baseBranch` and `targetBranch`. 3. A CSV file that maps source files to file owners. The program should: 1. Use a Git library, such as JGit, to compare `baseBranch` and `targetBranch`. 2. Produce the list of file paths that were changed between the two branches. 3. Read the CSV file containing ownership information. Each row has the format: ```text file_path,owner ``` Example: ```text src/payments/ChargeService.java,alice src/payments/RefundService.java,bob src/common/JsonUtil.java,alice ``` 4. Count how many changed files are owned by each owner. 5. Return the owner who owns the largest number of changed files. If a changed file does not appear in the CSV file, ignore it. If there is a tie, return any one of the tied owners. If no changed file has an owner, return an empty result.

Quick Answer: This question evaluates proficiency with version control diffs, repository library APIs, file I/O and CSV parsing, and data aggregation to map changed files to their owners.

You are building an automated reviewer picker for a pull request. In production, a Git library such as JGit would compare two branches. In this problem, each branch is already represented as a list of [file_path, file_version] pairs. A file is considered changed if: 1. it exists in only one branch, or 2. it exists in both branches but the file_version is different. You are also given a CSV string where each non-empty line has the format: file_path,owner Your task is to count how many changed files belong to each owner and return the owner with the largest count. Rules: - Ignore changed files that do not appear in the CSV. - If no changed file has an owner, return an empty string. - If multiple owners are tied, any one of them is acceptable. The reference solution returns the lexicographically smallest tied owner to keep the output deterministic.

Constraints

  • 0 <= len(base_files), len(target_files) <= 100000
  • 0 <= number of non-empty CSV rows <= 100000
  • Each file_path is unique within base_files and within target_files
  • file_version is an opaque string and should only be compared for equality

Examples

Input: ([['src/payments/ChargeService.java', 'a1'], ['src/payments/RefundService.java', 'b1'], ['src/common/JsonUtil.java', 'c1']], [['src/payments/ChargeService.java', 'a2'], ['src/payments/RefundService.java', 'b1'], ['src/common/JsonUtil.java', 'c2'], ['src/payments/NewService.java', 'd1']], 'src/payments/ChargeService.java,alice\nsrc/payments/RefundService.java,bob\nsrc/common/JsonUtil.java,alice\nsrc/payments/NewService.java,carol')

Expected Output: 'alice'

Explanation: Changed files are ChargeService, JsonUtil, and NewService. alice owns 2 of them, carol owns 1, so the answer is alice.

Input: ([['src/a.java', '1'], ['src/b.java', '1'], ['src/c.java', '1']], [['src/b.java', '2'], ['src/c.java', '1'], ['src/d.java', '1']], 'src/a.java,bob\nsrc/b.java,bob\nsrc/d.java,alice')

Expected Output: 'bob'

Explanation: src/a.java was deleted, src/b.java was modified, and src/d.java was added. bob owns 2 changed files and alice owns 1.

Input: ([['src/a.java', '1']], [['src/a.java', '2'], ['src/b.java', '1']], 'src/c.java,alice')

Expected Output: ''

Explanation: src/a.java and src/b.java changed, but neither appears in the ownership CSV, so no reviewer can be assigned.

Input: ([], [], '')

Expected Output: ''

Explanation: There are no files in either branch, so there are no changed files and no owner to return.

Input: ([], [['src/utils/Parser.java', 'v1']], '\nsrc/utils/Parser.java, dana \n')

Expected Output: 'dana'

Explanation: The file was added in the target branch. Blank CSV lines are ignored and surrounding spaces are trimmed, so the owner is dana.

Hints

  1. Convert each branch's file list into a dictionary so you can compare versions by path in O(1).
  2. Parse the CSV into a file_path -> owner map, then scan the union of paths from both branches and count only the changed ones.
Last updated: May 23, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Generate Account Email Notifications - Stripe (medium)
  • Calculate Transaction Fees - Stripe (medium)
  • Build an Account Transfer Ledger - Stripe (medium)
  • Implement Validation and String Compression - Stripe (hard)
  • Compute transaction fees from a CSV string - Stripe (hard)