Company: Razorpay
Difficulty: medium
Servers Time In distributed computing, one of the common subroutines for the servers is to pass what they computed to one special server called master that uses those results they computed to combine them together. Your company has n servers that are numbered from 1 to n . The master server has number n . Each server i can pass direct messages to servers i + sendTime[i] and i - sendTime[i] , providing that servers with those numbers exist. Passing a direct message lasts 1 second, and message channels have an unlimited capacity. Now, all servers want to pass their messages to the master server. How long would each server take to pass its message to the master server? The goal is to calculate, for each server, the minimum time needed to pass messages to the master. If there is a server that can\'t pass messages to the master, the answer for that server would be -1 . Input Format The first line contains an integer, n , denoting the number of servers. Each line i of the n subsequent lines