3
// In case string is duplicated, check if string has any duplicate letters4
bool dupeCase(string s) {5
unordered_set<char> letters;7
if (letters.count(it)) { // Found dupe letter (they can be swapped)13
return false; // all letters unique16
bool buddyStrings(string s, string goal) {18
if (goal.length() != s.length()) return false;19
// If strings are the same, use diff. method20
if (s == goal) return dupeCase(s);21
// Track index of differences23
for (int i = 0; i < s.length(); i++) {24
if (s[i] != goal[i]) { // If diff found25
if (diff.size() > 2) { // If this is third diff, return false27
} else { // If not store in diff array32
// If only one diff found, return false33
if (diff.size() == 1) return false;34
// else return if swap works35
return (s[diff[0]] == goal[diff[1]] && s[diff[1]] == goal[diff[0]]);