{"id":61,"date":"2021-01-10T13:16:15","date_gmt":"2021-01-10T05:16:15","guid":{"rendered":"https:\/\/fireinsect.top\/?p=61"},"modified":"2021-02-16T22:48:35","modified_gmt":"2021-02-16T14:48:35","slug":"%e5%9b%9e%e6%96%87%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%88%a4%e6%96%ad","status":"publish","type":"post","link":"https:\/\/fireinsect.top\/index.php\/2021\/01\/10\/%e5%9b%9e%e6%96%87%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%88%a4%e6%96%ad\/","title":{"rendered":"\u56de\u6587\u5b57\u7b26\u4e32\u5224\u65ad"},"content":{"rendered":"\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java line-numbers\">public class Demo {\n\n  \/\/ \u5224\u65ad\u662f\u5426\u4e3a\u56de\u6587\u5b57\u7b26\u4e32\n  public static boolean isPalindrome(String content) {\n    int start=0;\n    int end=content.length();\n    while(end&gt;start){\n      if(content.charAt(end)!=content.charAt(start)){\n        return false;\n      }\n      end--;\n      start++;\n    }\n    return true;\n  }\n\n  public static void main(String[] args) {\n    System.out.println(isPalindrome(\"\u6d1e\u5e18\u6c34\u6302\u6c34\u5e18\u6d1e\"));\n    System.out.println(isPalindrome(\"\u4e0a\u6d77\u81ea\u6765\u6c34\u6765\u81ea\u6d77\u4e0a\"));\n    System.out.println(isPalindrome(\"maddam\"));\n    System.out.println(isPalindrome(\"m\"));\n    System.out.println(isPalindrome(\"maxcam\"));\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u5206\u6790\uff1a<\/p>\n\n\n\n<p>\u5728\u5b50\u51fd\u6570\u4e2d\u5148\u8bbe\u5b9astart\u3001end\u4e24\u4e2a\u6574\u578b\u53d8\u91cf\uff0c\u5206\u522b\u8bb0\u51650\u548c\u5b57\u7b26\u4e32\u957f\u5ea6.length()<\/p>\n\n\n\n<p>\u4f7f\u7528while\u5faa\u73af\u76f4\u5230end&lt;=start<\/p>\n\n\n\n<p>\u6bcf\u4e00\u6b21\u5faa\u73af\u90fd\u5224\u65ad\u7b2c(start)\u7684\u5b57\u7b26\u548c\u7b2c(end)\u7684\u5b57\u7b26\u662f\u5426\u76f8\u540c\uff0c\u4e0d\u540c\u5219\u8df3\u51fa<\/p>\n\n\n\n<p>\u5e76\u6bcf\u6b21\u5faa\u73af\u7ed3\u5c3eend&#8211;\uff0cstart++<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[1,7],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-wcd","category-7"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/61"}],"collection":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":3,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}