Lexicographical concatenation of all substrings of a string | GeeksforGeeks

preview_player
Показать описание

This video is contributed by Ishmeet Kaur

Please Like, Comment and Share the Video among your friends.

Install our Android App:

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

Thanks Igor Carpanese for pointing out that the time complexity in worst case would be O(n³).
As for substr, even though time complexity is not specified, depends upon the length of substring requested. And substr is called inside code with complexity O(n²).

GeeksforGeeksVideos
Автор


Correct me If m wrong we don't need sorting to get the desired result as the O/P shown at 0:27 seconds.

jaatharsh
Автор

The time complexity of std::string::substr method is O(n). [1]

You call std::string::substr O(n²) times, so the final time complexity should be O(n³), shouldn't it?

carpanese
visit shbcf.ru