Suppose now we have:
String[] = {
"Name:John, State:MA, City:Boston, Degree:Master",
"Name:Alex, State:CA, City:San Diego, Degree:PhD",
"Name:Aaron, State:NY, City:NYC, Degree:Master",
"Name:Lily, State:MA, City:Worcester, Degree:Master",
}
How I'd like to find ALL that contain both "State:MA"
and "Degree:Master"
; so obviously that'll be line 1 and 4.
So it looks like SQL database query but I need to implemented using Java or Python.
Also, the input data is supposed be very big, so I'm actually considering more efficient ways like Trie
to store the information.
But usually Trie is supposed for prefix string question; say, given a list of strings we'd like to find all strings that contain pattern he
,
so final list could be like:
he, hell, help, hello....
While for my question, the two patterns they are not continuous together; but Trie indeed can save lots of space for big input.
So any ideas to solve such multiple pattern matching using Trie? Or other data structures I don't know?
Thanks