Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
string match2
//Title of this code //g++ 4.8.2 #include <iostream> bool match(const std::string& str1, const std::string& str2, int err, unsigned i = 0, unsigned j = 0) { if (i >= str1.length() || j >= str2.length() || err < 0) return false; if (str1[i] != str2[j]) --err; if (i == str1.length() - 1 && j == str2.length() - 1 && err >= 0) return true; return match(str1, str2, err, i + 1, j + 1) || match(str1, str2, err, i + 1, j) || match(str1, str2, err, i, j + 1); } bool match(const std::string& str1, const std::string& str2, int err, unsigned i = 0, unsigned j = 0) { if (i >= str1.length() || j >= str2.length() || err < 0) return false; while (str1[i] == str2[j] && i < str1.length()-1 && j < str2.length()-1) { ++i; ++j; } if (i < str1.length() && j < str2.length() && str1[i] != str2[j]) --err; if (i == str1.length() - 1 && j == str2.length() - 1 && err >= 0) return true; return match(str1, str2, err, i + 1, j + 1) || match(str1, str2, err, i + 1, j) || match(str1, str2, err, i, j + 1); } int main() { std::cout << match("abba", "abba", 1); }
run
|
edit
|
history
|
help
0
1163. Last Substring in Lexicographical Order
SFML ANIMATOR
2021, M2, Simulare;S3: 2
point to a rvalue
Podejrzana karteczka :0
count pairs with given sum hashing
SubprogramModificat
Odwrócone podciągi
test yield
Graph Theory On Strings