In a jail, some pairs of prisoners are chained together to make it more difficult for them to escape. A group of rebels has decided to escape, and one important part of their plan involves pressing two distant buttons simultaneously. They must determine the two prisoners best suited for this task.
Given the configuration of chains between prisoners, return the maximum distance that can be achieved between two prisoners. If there is no limit to that distance, return -1. You will be given a String chain, where the ith character of the jth element represents the length of the chain between prisoners i and j:
'0'-'9': Distances 0 to 9 feet, in order.
'a'-'z': Distances 10 to 35 feet, in order.
'A'-'Z': Distances 36 to 61 feet, in order.
' ': Space means there is no chain between that pair of prisoners.