188 days ago · Tech · hide · Fediverse post

The challenge Find the longest substring of a string where characters are in non-decreasing alphabetical order. If multiple substrings share the maximum length, return the first one. Example: the longest alphabetical substring in "asdfaaaabbbbcttavvfffffdf" is "aaaabbbbctt" (length 11). Inputs can be up to 10,000 characters, so the solution must be O(n). Solution 1: index tracking (fastest, O(1) memory) Track the start of the current run and the best run seen so far — only indices, no substrings:

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town