add longest substring directory