Below is my code to find the palindromes in an array of strings using 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++;
}
}
}
Can anyone tell me how to implement the above without using Hashing and with O(n) time complexity?