Company: Microsoft
Difficulty: medium
Short Message Service There is a metro rail line with k stations numbered from 0 to k-1 . There is a direct connection between stations if their numbers differ by one. Passengers can ride the metro line in both directions. The fee for boarding the train is 1 . Every time a passenger travels between two adjacent stations, the fee increases by 2 . The metro system charges money at the end of each day based on the passenger\'s travel history for that day. There is a total fee limit for a single day. The passenger cannot be charged more than the limit, even if their associated travel fees exceed the limit. The limit depends on the maximum station number the passenger visited during the day. You are given arrays start and dest of length N , describing all the metro rides the passenger took during the day. During the x-th ride, the passenger boarded the train at start[x] and left the train at station dest[x] . You are also given an array limit of length K . If the largest station number the