PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Crusoe

Calculate charge with a single price override

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of interval arithmetic, overlap detection and aggregation for time-based billing, plus careful edge-case handling of inclusive/exclusive boundaries within the Coding & Algorithms domain.

  • medium
  • Crusoe
  • Coding & Algorithms
  • Software Engineer

Calculate charge with a single price override

Company: Crusoe

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are billing a customer based on *usage intervals* and a *single temporary price override*. ## Definitions - A usage record is an interval `[start, end)` where `start` is inclusive and `end` is exclusive. - `defaultPrice` is the price per unit time (e.g., per day) when no override applies. - An override is: - `override.period = [overrideStart, overrideEnd)` - `override.price` = the price per unit time during the override period. ## Task Given: - `usageRecords: []Interval` (each `Interval` is `[start, end)`) - `defaultPrice: int` - `override: PriceOverride` Compute the **total charge** across all usage time, where: - Any portion of usage that overlaps `override.period` is billed at `override.price`. - Any portion of usage outside `override.period` is billed at `defaultPrice`. Return the total charge as an integer. ## Notes / Edge cases to handle - Usage may be **fully outside**, **fully inside**, or **partially overlap** the override period. - Assume inputs are valid (e.g., `start < end`, prices are non-negative). - Clarify in your solution whether `usageRecords` can overlap each other; if they can, ensure you do not double-bill overlapping usage time (e.g., by merging first). ## Example (conceptual) If `defaultPrice = 10`, override period is `[2, 6)` with `override.price = 5`, and a usage record is `[1, 4)`, then: - `[1,2)` billed at 10 - `[2,4)` billed at 5

Quick Answer: This question evaluates understanding of interval arithmetic, overlap detection and aggregation for time-based billing, plus careful edge-case handling of inclusive/exclusive boundaries within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Interval Overrides and Top-K Strings - Crusoe (easy)
  • Print a binary tree as aligned text - Crusoe (medium)
Crusoe logo
Crusoe
Feb 12, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
20
0
Loading...

You are billing a customer based on usage intervals and a single temporary price override.

Definitions

  • A usage record is an interval [start, end) where start is inclusive and end is exclusive.
  • defaultPrice is the price per unit time (e.g., per day) when no override applies.
  • An override is:
    • override.period = [overrideStart, overrideEnd)
    • override.price = the price per unit time during the override period.

Task

Given:

  • usageRecords: []Interval (each Interval is [start, end) )
  • defaultPrice: int
  • override: PriceOverride

Compute the total charge across all usage time, where:

  • Any portion of usage that overlaps override.period is billed at override.price .
  • Any portion of usage outside override.period is billed at defaultPrice .

Return the total charge as an integer.

Notes / Edge cases to handle

  • Usage may be fully outside , fully inside , or partially overlap the override period.
  • Assume inputs are valid (e.g., start < end , prices are non-negative).
  • Clarify in your solution whether usageRecords can overlap each other; if they can, ensure you do not double-bill overlapping usage time (e.g., by merging first).

Example (conceptual)

If defaultPrice = 10, override period is [2, 6) with override.price = 5, and a usage record is [1, 4), then:

  • [1,2) billed at 10
  • [2,4) billed at 5

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Crusoe•More Software Engineer•Crusoe Software Engineer•Crusoe Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

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