PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Capital One

Implement minimal-cost overtime/contractor allocation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability in cost-minimizing resource allocation and algorithm design, specifically testing greedy strategies, sorting-based selection, tie-breaking rules, constraint handling, and time-complexity analysis.

  • Medium
  • Capital One
  • Coding & Algorithms
  • Data Scientist

Implement minimal-cost overtime/contractor allocation

Company: Capital One

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You must cover H extra engineering hours this week at minimum cost using employee overtime and optional contractors. Each employee i has a maximum overtime cap cap[i] and an overtime cost rate cost_emp[i] per hour. Contractors have unlimited availability at rate cost_contractor per hour. Return both the minimal total cost and an allocation of hours per employee and contractors. Constraints: 0 ≤ hours[i] ≤ cap[i]; sum(hours[i]) + contractor_hours = H. If multiple allocations have the same minimal cost, prefer the one that minimizes contractor_hours; if still tied, minimize the variance of employee overtime hours. Input example: H = 120 cap = [8, 20, 40, 12] cost_emp = [55, 35, 60, 45] cost_contractor = 50 Questions: (a) Describe and implement an O(n log n) algorithm that returns the allocation and total cost. Justify correctness and complexity. (b) Extend your algorithm to handle per-employee overtime tiering (first t[i] hours at rate r1[i], remaining at r2[i] > r1[i]) and a global contractor capacity C. Provide the modified approach and complexity. (c) For the input above, what is the exact optimal allocation and cost?

Quick Answer: This question evaluates a candidate's ability in cost-minimizing resource allocation and algorithm design, specifically testing greedy strategies, sorting-based selection, tie-breaking rules, constraint handling, and time-complexity analysis.

Related Interview Questions

  • Solve Four Coding Assessment Tasks - Capital One (medium)
  • Write SQL using joins and window functions - Capital One (medium)
  • Review Preprocessing Code and Tests - Capital One (easy)
  • Remove nodes with a given value - Capital One (medium)
  • Solve multiple algorithmic interview questions - Capital One (hard)
Capital One logo
Capital One
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Coding & Algorithms
5
0

You must cover H extra engineering hours this week at minimum cost using employee overtime and optional contractors. Each employee i has a maximum overtime cap cap[i] and an overtime cost rate cost_emp[i] per hour. Contractors have unlimited availability at rate cost_contractor per hour. Return both the minimal total cost and an allocation of hours per employee and contractors. Constraints: 0 ≤ hours[i] ≤ cap[i]; sum(hours[i]) + contractor_hours = H. If multiple allocations have the same minimal cost, prefer the one that minimizes contractor_hours; if still tied, minimize the variance of employee overtime hours. Input example: H = 120 cap = [8, 20, 40, 12] cost_emp = [55, 35, 60, 45] cost_contractor = 50

Questions: (a) Describe and implement an O(n log n) algorithm that returns the allocation and total cost. Justify correctness and complexity. (b) Extend your algorithm to handle per-employee overtime tiering (first t[i] hours at rate r1[i], remaining at r2[i] > r1[i]) and a global contractor capacity C. Provide the modified approach and complexity. (c) For the input above, what is the exact optimal allocation and cost?

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Capital One•More Data Scientist•Capital One Data Scientist•Capital One Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,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.