1234567891011121314 |
- /* A pair of strings form a strange pair if:
- * 1st string's first letter = 2nd string's last letter.
- * 1st string's last letter = 2nd string's first letter.
- * Create a function that returns true if a pair of strings
- * constitutes a strange pair, and false otherwise.
- */
- /* compare wordA first character with wordB last character
- * compare wordA last character with wordB first character
- * return true if both comparisons are equal
- */
- bool isStrangePair(std::string str1, std::string str2) {
- return str1[0]==str2.back() && str1.back()==str2[0];
- }
|