Advertisement
MohamedAbdel3al

palindrome

Dec 10th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class Solution {
  2. public:
  3. bool is_palindrome(vector < char >& s){
  4. int l = 0, r = s.size() - 1;
  5. while(l < r)
  6. if(s[l++] != s[r--]) return false;
  7. return true;
  8. }
  9. void print(){
  10. cout << (is_palindrome(s) ? "true" : "false");
  11. }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement