Write a function named intersection that takes in two strings named s1 and s2 and returns a string. This function will find all the characters that exist in BOTH s1 and s2 and return them as a string. C++
#include <iostream>
#include <string>
using namespace std;
string intersection(string s1, string s2) {
string result;
bool found;
for (int i = 0; i < s1.size(); ++i) {
found = false;
for (int j = 0; j < s2.size(); ++j) {
if (s1[i] == s2[j]) {
found = true;
}
}
if (found) {
result += s1[i];
}
}
return result;
}
int main() {
cout << intersection("abcde", "bdef") << endl;
return 0;
}
Write a function named intersection that takes in two strings named s1 and s2 and returns...