FastPrepParking Fee Calculator
Problems/Parking Fee Calculator

Parking Fee Calculator

Breeze logoBreeze● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Breeze coding round for a full-time senior software engineer role. The round was a practical task, not a classic algorithm question: the candidate first asked questions and planned without AI help, then built the function with an AI coding tool. The task was to work out what a car owes for one stay in a car park: the first 30 minutes are free, every hour or part of an hour costs $3, and there is a daily maximum.

The interviewer confirmed that 1.5 hours costs $6, that a 45-minute stay is billed as one full hour (the free half hour is not taken off first), and that each call is one entry and one exit. The $24 daily maximum comes from the author's own notes in the report, because the amount was hard to hear on their recording. The interviewer did not confirm how stays longer than a day are billed. Here we use the rule from the candidate's solution: each full 24 hours from entry costs $24, the hours left over are billed at $3 each up to $24, and the free half hour counts once per stay. We also take times as Unix timestamps in seconds and return whole dollars.

Our version is about 85% the same as the reported question.

A car park charges a car for one stay. You are given the time the car came in, entryTime, and the time it left, exitTime. Return the fee for the stay in whole dollars.

Both times are Unix timestamps in seconds, and exitTime is never earlier than entryTime. The stay lasts exitTime - entryTime seconds.

The fee rules are:

  • A stay of 30 minutes (1800 seconds) or less is free.
  • A longer stay is billed from the moment the car came in, so the free 30 minutes are not taken off first. Every hour costs $3, and a part of an hour counts as a whole hour. For example, 45 minutes costs $3 and 1 hour 30 minutes costs $6.
  • One day costs at most $24.

For this exercise, a day is each full 24 hours counted from entryTime, not a calendar date, so passing midnight changes nothing. Each full 24 hours costs $24. The time left after the full days is billed at $3 per hour or part of an hour, up to $24. The free 30 minutes count only once for the whole stay, so any time left after a full day is billed even when it is short.

Function

calculateParkingFee(entryTime: long, exitTime: long) → long

Examples

Example 1

entryTime = 1793700000exitTime = 1793701800return = 0

The car stays exactly 30 minutes, which is still inside the free half hour, so the fee is 0.

Example 2

entryTime = 1793700000exitTime = 1793702700return = 3

The stay is longer than 30 minutes, so the whole 45 minutes is billed. 45 minutes is part of one hour, so the fee is 3. The free half hour is not taken off first.

Example 3

entryTime = 1793700000exitTime = 1793705400return = 6

1 hour 30 minutes starts a second hour, so it is billed as 2 hours: 2 * 3 = 6.

Example 4

entryTime = 1793700000exitTime = 1793782800return = 24

23 hours would cost 23 * 3 = 69, but one day costs at most 24.

Example 5

entryTime = 1793700000exitTime = 1793794200return = 33

The first full 24 hours cost 24. The 2 hours 10 minutes left over start 3 hours, so they cost 3 * 3 = 9. The total is 24 + 9 = 33.

Constraints

  • 0 <= entryTime <= exitTime <= 10^10

Similar questions at other companies

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
  • Exponential Backoff DelaysWonderful · PHONE SCREEN
  • Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
  • Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
  • Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
  • Smaller Clock Hand AngleAmazon · PHONE SCREEN
See Breeze hiring insights
Saved
class Solution {
    public long calculateParkingFee(long entryTime, long exitTime) {
        // Write your code here.
    }
}
Checking account…