![]() |
AtMostOneConnectFlights |
|
All cities index from left to the right. Let be the set of all index, left to index , who has one direct flight. Let be the set of all index, left to index , who need one connecting flight. It is to be crucial. When index is added, a direct flight is needed and accordingly is part of and all is part of and no need flights added for . So consider index in and the would-be-shrink set of be denoted by staring at . Let be the largest index in , with a convenient 0 when is empty, so a is wanted/added in and need to be deleted from . is wanted/added in and need to be delete from . is wanted/added in and n need to be delete from . And so on so forth. Starting from two city. . 3 comes into picture. Temporarily, . Final. 4 comes into picture. Temporarily, . Final. 5 comes into picture. Temporarily, . Final. Then. Arrange the index from to 1 rather than from 1 to to have the backward flight map. So the computation size is 2 times only. So overall, this is the best map. …. Searching largest index of . Being searching, at log(n) by binary search when the set is organized. But?
|
|