I have a two dimensional string array look like this:
The first column contains characters of many strings, other columns are extra data for character.
I want to search a string (maybe change to array character) in this array to get all match indexes (start - end). For example, when I search with key "next", the result should be [5 - 8], [13 - 16] (the highlight parts in image above).
Shortly, I need a method look like this:
public static List<Interval> search(String searchText, String[][] data, int columnsCount, int rowCount){
// Convert search text to String array
String[] searchArr = getStringArray(searchText);
// then search in data
}
// where Interval is:
public class Interval{
public int start;
public int end;
}
Is there any fast way to search like this,cause my data is very large?
Thanks in advance!
BinarySearch
.Red Black Tree
orAVL Tree
can be implemented for more effective search. – erencan 26 mins ago