mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-24 10:37:33 +08:00
18 lines
344 B
Go
18 lines
344 B
Go
package leetcode
|
|
|
|
import "strings"
|
|
|
|
func findOcurrences(text string, first string, second string) []string {
|
|
var res []string
|
|
words := strings.Split(text, " ")
|
|
if len(words) < 3 {
|
|
return []string{}
|
|
}
|
|
for i := 2; i < len(words); i++ {
|
|
if words[i-2] == first && words[i-1] == second {
|
|
res = append(res, words[i])
|
|
}
|
|
}
|
|
return res
|
|
}
|