Video courses for company/skill based Preparation
Purchase mock tests for company/skill building
TCS DRC Coding Question-1
Problem Statement –
A marathon is a long-distance race with an official distance of 42.195 kilometers(26 miles 385 yards), usually run as a road race or footrace. A local marathon was organized at Bavdhan, Pune. The distance actually covered by the participants has been recorded in an array R[ ] which is an integer array holding the values in kilometers. If there are N number of participants who started running at a particular time, then the size of R is N. The participants should cover a distance more than 0.0 km to get recorded in array R[ ].
Find the maximum distances covered by the 3 highest racers excluding finishers. If there are only one or two racers excluding finishers, give their distances covered.
R[ ] will be the input float array. Write code to take the Input array R[ ], and return 3 maximum distances excluding Finishing Distance d, d = 42.195 km
Enter the distances covered by racers in Marathon(Kilometers) please
(press q to terminate):
Highest Distances excluding Finishers:
[41.2, 40.0, 38.9]
R =  print("Enter the distances covered by racers in Marathon(Kilometers) please (press q to terminate):") num = input() while num !='q': R.append(float(num)) num = input() result = sorted(R) for i in result: if i < 0 : print("Invalid Input") break print(result[-4:-7:-1])