There's a group of people sitting in a row of seats. Each seat can hold only one person. Your goal is to arrange the people so they're all sitting together and there are no empty seats between people. You are given a String[] s representing the row of seats from left to right. The ith element of s is '.' if the ith seat is empty and uppercase 'X' if it's occupied. Each seat is one unit of length wide. There is no space between adjacent seats.
The distance that one person needs to travel to relocate from the ith seat to the jth seat is the absolute value of (i - j) units. Return the minimum possible total distance in units that the people must travel in order to achieve your goal.
|