# Solution for Man in the Mirror
https://acm.cs.nthu.edu.tw/problem/13991/
This question is a simplified version of 'Squidward Musical' in HW3.
Essentially, checking for palindromes is just simultaneously checking the characters from both sides to see if any of them are all the same. If there is one that is not the same, then it isn't a palindrome.
If one stores the number palindromes in an array (e.g. [n][1000]), there will be too much palindromes to store and it will cause a memory limit exceeded error.
Additionally the question states that the max length of string is 10^6 which is equal to 1000000. Many students only wrote 10^5 as their array size. Therefore the final array size should be 1000001 at least. We need one extra space to store the '\0'
```cpp=
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool isPalindrome(const char *str) {
int left = 0;
int right = strlen(str) - 1;
while (left < right) {
if (str[left] != str[right]) {
return false;
}
left++;
right--;
}
return true;
}
int main() {
char input[1000001];
int q;
scanf("%d", &q);
while(q--)
{
scanf("%s", input);
if (isPalindrome(input)) {
printf("Yes\n");
} else {
printf("No\n");
}
}
return 0;
}
```