Check Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters.
Palindrome
Example:
From that being said, you are required to return a boolean value from the function that has been asked to implement.
Input Format:
Output Format:
Note:
Constraints:
Sample Input 1 :
Sample Output 1 :
Sample Input 2:
Sample Output 2:
#include <iostream>
#include <cstring>
using namespace std;
#include "solution.h"
int lenght(char str[]){
int count=0;
for (int i=0;str[i]!='\0';i++){
count++;
}
return count;
}
bool checkPalindrome(char str[]) {
// Write your code here
for(int i=0;i<lenght(str);i++){
if(str[i]!=str[lenght(str)-i-1]){
return false;
}
}
return true;
}
int main() {
int size = 1e6;
char str[size];
cin >> str;
cout << (checkPalindrome(str) ? "true" : "false");
}
Comments
Post a Comment