java - Efficient String text search -
i'd create method searches small string of text (usually no more 256 characters) existence of of 20 different words. if finds 1 in text regardless of case returns true.
the method executed quite bit (not crazy amount) has efficient possible. suggest best here?
the 20 words not change. static. text scan does.
i'd suggest: add words in input text set
- it's 256 characters after all, , adding them o(n)
operation.
after can test each of 20 or words membership using contains()
operation of set
, o(1)
.
Comments
Post a Comment