Find and Replace Pattern(C++查詢和替換模式)
class Solution {
public:
bool compare(string &s,string &pattern,unordered_map<char,vector<int>> &mp) {
unordered_map<char,vector<int>> mw;
for(int i=0;i<s.length();i++) {
mw[s[i]].push_back(i);
}
for(int i=0;i<s.length();i++) {
if(mw[s[i]]!=mp[pattern[i]]) return false;
}
return true;
}
vector<string> findAndReplacePattern(vector<string>& words, string pattern) {
unordered_map<char,vector<int>> mp;
for(int i=0;i<pattern.length();i++) {
mp[pattern[i]].push_back(i);
}
vector<string> v;
for(int i=0;i<words.size();i++) {
if(compare(words[i],pattern,mp)) v.push_back(words[i]);
}
return v;
}
};
相關文章
- ultraedit使用_查詢替換find_replace 幫助手冊
- 字串查詢和替換字串
- [leetcode] 890. Find and Replace PatternLeetCode
- js字串查詢和替換功能JS字串
- vim查詢替換
- Linuxvivim查詢和替換字串命令Linux字串
- js replace 全域性替換JS
- 在LoadRunner中查詢和替換字串字串
- PostgreSQL 查詢替換函式SQL函式
- js replace替換字串,同時替換多個方法JS字串
- Python字串string的查詢和替換Python字串
- vi查詢替換命令詳解
- 如何在word中進行查詢與替換 word文件中的替換與查詢功能
- 替換快捷鍵ctrl加什麼 word查詢和替換快捷鍵是什麼
- JavaScript replace()替換字串中指定字元JavaScript字串字元
- js replace()方法進行字串替換JS字串
- PHP字串替換substr_replace與str_replace函式PHP字串函式
- SQL中的替換函式replace()使用SQL函式
- 【Hive】字串替換函式translate和regexp_replaceHive字串函式
- D4.玩轉查詢與替換
- vim下多行查詢替換簡單命令
- 命行下的查詢與替換字串字串
- js使用replace()函式替換所有指定字元JS函式字元
- Word文件格式也能查詢與替換
- VC++基礎 字串的查詢與替換C++字串
- 批次word文件內容查詢替換的方法
- replace()方法替換字串內容程式碼例項字串
- javascript如何使用replace()函式替換所有指定字元JavaScript函式字元
- find 查詢檔案
- Python實用技法第24篇:正則:查詢和替換文字Python
- 常用的查詢find和定位locate的用法
- 使用正規表示式替換字串的方法(replace方法)字串
- C++設計模式——命令模式(command pattern)C++設計模式
- C++ 設計模式 裝飾模式(Decorator Pattern)C++設計模式
- c++涉及模式 橋接模式(bridge Pattern)C++模式橋接
- 使用sed 命令查詢和替換檔案中的字串的方法總結字串
- 使用 sed 命令查詢和替換檔案中的字串的 16 個示例字串
- Linux的VI (連線行,查詢和替換,多檔案編輯)Linux