Traffic Light Waiting Time

JavaScript Medium 3 views
Back to Questions

Problem Description

A traffic light has 3 phases: Red, Yellow, Green with fixed durations. You are given current phase (R/Y/G) and how many seconds are left in that phase. Find how many seconds you will wait to see Green (including 0 if already Green).

Input Format

One line: phase rem r y g.

Output Format

One integer wait seconds.

Sample Test Case

Input:
R 5 10 3 7
Output:
5

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev