Traffic Signal Green Time Allocation
Traffic Signal Green Time Allocation
MediumArrays0% accepted
Bangalore traffic engineers monitor vehicle counts at a 4-way intersection (North, South, East, West). They need to allocate green light duration: 50% to busiest lane, 30% to second busiest, 20% to third, 0% to least busy.
Approach
Given vehicle counts for 4 lanes, allocate green signal percentages [50%, 30%, 20%, 0%] to lanes ranked by traffic volume.
Input
4
100 50 30 20
Output
[50, 30, 20, 0]
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards