Looking at this problem, I need to:
1. Build the expected pattern: `<3` + word1 + `<3` + word2 + ... + wordn + `<3`
2. Check if this pattern exists as a **subsequence** in the received message (since random characters can be inserted anywhere)
A subsequence means characters appear in the correct order, but not necessarily consecutively.
**Algorithm:**
- Build the expected pattern string
- Use two pointers to check if the pattern is a subsequence of the message
- For each character in the message, if it matches the current pattern character, advance the pattern pointer
- If we match all pattern characters, output "yes", otherwise "no"
Let me trace through Example 2:
- Pattern: `<3i<3love<3you<3`
- Message: `i<3love<3you<3`
- Looking for `<` → skip 'i', find `<` at position 1
- Looking for `3` → find '3' at position 2
- Looking for `i` → remaining message is `love<3you<3`, no 'i' found
- Result: "no" ✓
Example 5:
- Pattern: `<3a<3`
- Message: `<3a<3a<3`
- All pattern chars found in order: "yes" ✓
```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
n, _ := strconv.Atoi(scanner.Text())
var pattern strings.Builder
pattern.WriteString("<3")
for i := 0; i < n; i++ {
scanner.Scan()
word := scanner.Text()
pattern.WriteString(word)
pattern.WriteString("<3")
}
scanner.Scan()
message := scanner.Text()
p := pattern.String()
j := 0
for i := 0; i < len(message) && j < len(p); i++ {
if message[i] == p[j] {
j++
}
}
if j == len(p) {
fmt.Println("yes")
} else {
fmt.Println("no")
}
}
```