This problem is based on a simple parking lot rule. The first two hours cost a flat price, and any extra hours after that add more to the bill.
In this version, parking costs 5 for up to 2 hours. After that, each extra hour adds 3 more.
For example, if a car stays for 4 hours, the total fee is 11. That is 5 for the first two hours, plus 6 for the next two hours.
So the task is to check the number of parking hours and calculate the final fee using those rules.
Example Input & Output
The first two hours cost 5, and the extra two hours add 6.
Exactly 2 hours still uses the base fee.
A short stay still uses the flat parking fee.
Algorithm Flow

Solution Approach
A good way to solve this is to separate the easy case from the extra-charge case.
If the parking time is 2 hours or less, the fee is always 5. That means you can return the base price right away.
If the parking time is more than 2 hours, you first figure out how many hours are extra.
The extra hour count is:
Then you multiply that value by 3 and add it to the base fee of 5.
The full update becomes:
So the logic is: small stay means flat price, longer stay means flat price plus extra hourly cost.
Best Answers
Solutions Coming Soon
Verified best solutions for this Challenge are still being analyzed and will be available soon.
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
