葉林
Linked with GitHub
# LeetCode - 1078. Occurrences After Bigram ### 題目網址:https://leetcode.com/problems/occurrences-after-bigram/ ###### tags: `LeetCode` `Easy` `字串` ```cpp= /* -LeetCode format- Problem: 1078. Occurrences After Bigram Difficulty: Easy by Inversionpeter */ class Solution { public: vector<string> findOcurrences(string text, string first, string second) { vector <string> answer; string last1 = "", last2 = "", buffer = ""; for (int i = 0; i != text.size(); ++i) if (text[i] == ' ') { if (last1 != "" && last2 != "") { if (last2 == first && last1 == second) answer.push_back(buffer); } last2 = last1; last1 = buffer; buffer = ""; } else buffer += text[i]; if (last1 != "" && last2 != "" && last2 == first && last1 == second) answer.push_back(buffer); return answer; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up