Orphan Backups

From programming_contest
Revision as of 02:41, 19 October 2021 by Kmk21 (talk | contribs) (Created page with "This problem asks us to find file/image/backup/index titles from one list which do not match another. The trick to this problem is not assuming anything about the input other...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This problem asks us to find file/image/backup/index titles from one list which do not match another. The trick to this problem is not assuming anything about the input other than what is specified. For instance, there is no guarantee that there is a file extension (*.txt, or similar), and there is no guarantee that there won't be '_' in the filename itself!. Therefore, the only valid way to convert from the backup to the original file name is to find the second to last '_' in the backup, and remove everything after it. One can leverage Tree and Hashsets to do the ordering and fast lookups.

It may seem attractive to use a regex to match (^FILENAME_[0-9]{1,10}_[a-zA-Z]{1,6}$) in order to match, however, this is too slow.