As reported: Microsoft SWE intern 2025 online assessment (Codility, "focus on correctness"), challenge 1 — metro fees.
A metro line has K stations numbered 0 … K − 1; stations whose numbers differ by one are directly connected, and trains run both ways.
A passenger rides N times in one day: ride x boards at start[x] and leaves at dest[x] (start[x] ≠ dest[x]). Each ride costs a boarding fee of 1 plus 2 for every station-to-station hop, so a ride over d stations costs 1 + 2d.
There is a daily limit: if the largest station number the passenger visited that day is Y, they are never charged more than limit[Y] in total. Return the amount charged at the end of the day.
Example 1
start = [1,0,2,4], dest = [2,2,0,5], limit = [3,17,7,4,5,17] -> 16
Rides cost 3, 5, 5 and 3 = 16. The largest station visited is 5 and limit[5] = 17, so no cap applies.
Example 2
start = [1,2,0,2,3], dest = [2,1,2,1,2], limit = [4,8,18,16,20] -> 16
Rides cost 3, 3, 5, 3, 3 = 17; the largest station is 3, capped at limit[3] = 16.
Example 3
start = [2,2], dest = [4,3], limit = [1,1,1,1,9,1,1] -> 8
Constraints: 1 ≤ N ≤ 30; 2 ≤ K ≤ 50; 0 ≤ start[x], dest[x] < K; start[x] ≠ dest[x]; 1 ≤ limit[i] ≤ 3000.
Code runner format: one JSON value per line: start, dest, limit (N and K are their lengths). Implement dailyFee(start, dest, limit); the harness prints the result.