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
Sort 0's 1's 2's
Wipro Problem 1: generate roll number
cpp permutations
1
List add
Tubee c++
Finding Ocean
A • Potato Sacks
DeltaX campus recruitment
NonparaH