Find First Palindromic String in the Array LeetCode solution in C++
1class Solution {2bool isPalindrome(string str) {3int i = 0;4int j = str.length() - 1;5while (i <= j) {6if (str[i] != str[j]) return false;7i++;8j--;9}10return true;11}1213public:14string firstPalindrome(vector<string> &words) {15for (int i = 0; i < words.size(); i++) {16if (isPalindrome(words[i])) return words[i];17}18return "";19}20};