Search a File Collection
Problem statement
Process an ordered batch of operations on an initially empty collection of unique, case-sensitive file paths.
ADD pathstores the path. Adding an existing path changes nothing.FIND fragmentfinds every stored path whose final filename containsfragment. Return matching paths in lexicographic order, joined by|, orNONEwhen no path matches.
Return one result string for each FIND operation; ADD operations do not add output entries.
Function
searchFiles(operations: String[]) → String[]Examples
Example 1
operations = ["ADD /docs/report.txt","ADD /tmp/notes.txt","FIND .txt","FIND port"]return = ["/docs/report.txt|/tmp/notes.txt","/docs/report.txt"]Both text files match the first query; only report.txt contains port.
Example 2
operations = ["ADD /a/photo.png","ADD /b/photo.png","ADD /a/photo.png","FIND photo","FIND .jpg"]return = ["/a/photo.png|/b/photo.png","NONE"]Duplicate insertion is ignored, and the second query has no matches.
Constraints
1 <= operations.length <= 10^4- Paths and fragments are nonempty printable strings without spaces or
|. - Every path contains at least one filename character after its final slash.