Check Speed Limit Warning
Given the current speed and the posted speed limit, determine whether a warning should be issued. Return true if the speed exceeds the limit, false otherwise.
For example, at speed 75 with limit 65, return true (speeding). At speed 60 with limit 65, return false (within the limit). At speed exactly 65 with limit 65, return false (not exceeding). At speed 0 with limit 25, return false.
Speed limit checking is a simple threshold comparison used in navigation apps, fleet management systems, and driver assistance features. It teaches the greater-than comparison operator and boolean return values — the simplest form of decision logic in programming.
The solution compares the current speed to the limit using the greater-than operator (>). If speed > limit, the driver is exceeding the speed limit and a warning should be issued. If speed is less than or equal to the limit, no warning is needed.
Edge cases include speed exactly equal to the limit (no warning), speed of 0 (no warning), and negative speeds which are not expected but would technically not exceed the limit.
Example Input & Output
Matching the limit is still allowed.
The speed is still within the allowed limit.
The speed is above the limit, so a warning is needed.
Algorithm Flow

Solution Approach
Compare the current speed to the speed limit using the greater-than operator.
Return the result of speed > limit. This expression evaluates to true when the current speed is strictly greater than the posted limit (indicating the driver is speeding) and false when the speed is at or below the limit. Using strict greater-than ensures that driving exactly at the speed limit is not considered a violation.
Time complexity is O(1), space complexity is O(1).
Best Answers
program check_speed_limit_warning
dictionary
speed, limit: integer
algorithm
input(speed, limit)
if speed > limit then
output("SLOW DOWN")
else
output("OK")
endif
endprogramComments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
