Byte by Byte

1078. Occurrences After Bigram.cpp 본문

개발 로그/알고리즘

1078. Occurrences After Bigram.cpp

CyberSoak 2021. 12. 15. 20:08

class Solution {
public:
    vector<string> findOcurrences(string text, string first, string second) {
        vector<string>s;
        vector<string>res;
        for(int i =0; i<text.size(); i++){
            string tmp ="";
            while(i!=text.size() && text[i]!=' '){
                tmp+= text[i++];
            }
            s.push_back(tmp);
        }
        
        for(int i =0; i<s.size()-2; i++){
            if(s[i]==first &&s[i+1]==second) res.push_back(s[i+2]);
        }
        return res;
    }
};

'개발 로그 > 알고리즘' 카테고리의 다른 글

1854. Maximum Population Year.cpp  (0) 2021.12.17
49. Group Anagrams.cpp  (0) 2021.12.16
1598. Crawler Log Folder.cpp  (0) 2021.12.15
1694. Reformat Phone Number.cpp  (0) 2021.12.15
575. Distribute Candies.cpp  (0) 2021.12.15