Find the highest response time
Problem statement
To find the biggest value in a list, walk through it while remembering the biggest one seen so far. Start by assuming the first item is the biggest. Then, for each item, if it is bigger than your current best, it becomes the new best.
Common mistake: replacing the best value without checking.
Wrong:for t in times: highest = tWithout the if t > highest check, every pass overwrites highest, so it ends up as the last item in the list, not the biggest.
Your task: given response times in milliseconds, [120, 95, 340, 180, 210], print the highest one.
Expected output:
340Approach
Start highest at the first item, then update it only when a bigger value shows up. Python has a built-in max(times) that does this in one call. Writing the loop yourself shows what max is doing underneath, and the same loop works in every language.
DSA connection: this one-pass "keep the best so far" loop is called a linear scan, and it comes back in many array problems.
times = [120, 95, 340, 180, 210]
highest = times[0]
for t in times:
if t > highest:
highest = t
print(highest)