1078. Bigram 分词
java代码:
class Solution {
public String[] findOcurrences(String text, String first, String second) {
String[] arr = text.split(" ");
List<String> list = new ArrayList<String>();
for (int i = 0; i < arr.length - 2; ++i) {
if (arr[i].equals(first) && arr[i + 1].equals(second)) {
list.add(arr[i + 2]);
}
}
String ans[] = list.toArray(new String[list.size()]);
return ans;
}
}