首页 > 其他分享 >BM88 判断是否为回文字符串

BM88 判断是否为回文字符串

时间:2023-02-19 10:58:06浏览次数:36  
标签:return string bool str BM88 字符串 size 回文


class Solution { public:     /**      * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可      *      * @param str string字符串 待判断的字符串      * @return bool布尔型      */     bool judge(string str) {         // write code here         if(str.size() < 2 ){             return true;         }         int l = 0,r = str.size()-1;         while(l < r){             if(str[l] != str[r]){                 return false;             }             l++;             r--;         }
        return true;
    } };

标签:return,string,bool,str,BM88,字符串,size,回文
From: https://www.cnblogs.com/starter-songudi/p/17134329.html

相关文章