Find First Palindromic String in the Array

PHOTO EMBED

Sat Oct 08 2022 19:17:09 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    string firstPalindrome(vector<string>& words) {
        int n=words.size();
        
        string temp="";
        for(int i=0;i<n;i++)
        {
            temp="";
            int n1=words[i].size();
            temp=words[i];
            for(int j=0;j<n1/2;j++)
            {
                swap(temp[j],temp[n1-j-1]);
            }
            if(temp==words[i])
            {
               return words[i];
            }
            else temp="";
        }
    return temp;
    }
};
content_copyCOPY

https://leetcode.com/problems/find-first-palindromic-string-in-the-array/