Orphan Backups
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.