Hello I am trying to find the palindromes in an array of strings . I have tried the brute force method with O(n2) time complexity
for(int i=0;i<s.length;i++) {
for(int j=i+1;j<s.length;j++) {
if(s[i] == reverse(s[j])) {
count++;
}
}
}
I am looking for a solution without using hashing and with O(n) time complexity or a better time complexity .
My problem is if I am on a particular index , I have to compare the element at that index with the remaining elements .
can anyone please help me solve this questions. TIA