{"id":2130,"date":"2023-10-06T18:50:08","date_gmt":"2023-10-06T10:50:08","guid":{"rendered":"https:\/\/white-night.club\/?p=2130"},"modified":"2023-11-09T11:07:51","modified_gmt":"2023-11-09T03:07:51","slug":"ad26","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/06\/ad26\/","title":{"rendered":"171.\u00a0Excel \u8868\u5217\u5e8f\u53f7"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>columnTitle<\/code>&nbsp;\uff0c\u8868\u793a Excel \u8868\u683c\u4e2d\u7684\u5217\u540d\u79f0\u3002\u8fd4\u56de&nbsp;<em>\u8be5\u5217\u540d\u79f0\u5bf9\u5e94\u7684\u5217\u5e8f\u53f7<\/em>&nbsp;\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">A -&gt; 1\nB -&gt; 2\nC -&gt; 3\n...\nZ -&gt; 26\nAA -&gt; 27\nAB -&gt; 28 \n...<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165:<\/strong> columnTitle = \"A\"\n<strong>\u8f93\u51fa:<\/strong> 1\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165: <\/strong>columnTitle = \"AB\"\n<strong>\u8f93\u51fa:<\/strong> 28\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;3:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165: <\/strong>columnTitle = \"ZY\"\n<strong>\u8f93\u51fa:<\/strong> 701<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= columnTitle.length &lt;= 7<\/code><\/li>\n\n\n\n<li><code>columnTitle<\/code>&nbsp;\u4ec5\u7531\u5927\u5199\u82f1\u6587\u7ec4\u6210<\/li>\n\n\n\n<li><code>columnTitle<\/code>&nbsp;\u5728\u8303\u56f4&nbsp;<code>[\"A\", \"FXSHRXW\"]<\/code>&nbsp;\u5185<\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u6570\u5b66\u63a8\u5bfc\uff1f<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u548c\u7b97\u6cd5\u6ca1\u4ec0\u4e48\u5173\u7cfb\u554a\uff0c\u867d\u7136\u9898\u89e3\u8bf4\u662f26\u8fdb\u5236\uff0c\u4f46\u6211\u5b8c\u5168\u6ca1\u5f80\u8fd9\u4e2a\u65b9\u9762\u60f3\u3002<\/p>\n\n\n\n<p>A=1\uff0cAA=27\uff0cAAA=703\u3002\u540e\u9762\u4e24\u8005\u5982\u679c\u5404\u81ea-1\u5c31\u90fd\u53ef\u4ee5\u88ab26\u6574\u9664\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6bcf\u591a\u4e00\u4f4d\u5b57\u6bcd\uff0c\u5e8f\u53f7\u5c31\u8981\u5728\u539f\u6709\u7684\u57fa\u7840\u4e0ax26\u518d+1\u3002\u611f\u89c9\u8fd9\u5c31\u662f\u627e\u89c4\u5f8b\u7684\u9898\uff0c\u8fc7\u3002<\/p>\n\n\n\n<p>\u53ef\u80fd\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f<code>\"FXSHRXW\"<\/code>\uff0c\u5b83\u521a\u597d\u662fint\u6700\u5927\u503c\u3002\u5982\u679c\u5199\u7684\u4ee3\u7801\u7b97\u51fa\u6765\u7684\u7ed3\u679c\u504f\u5927\u90a3\u80af\u5b9a\u4f1a\u6ea2\u51fa\u6709\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\r\npublic:\r\n    int titleToNumber(string columnTitle) {\r\n        int no=0;\r\n        int len=columnTitle.length();\r\n        for(int i=0;i&lt;len;i++)\r\n        {\r\n            if(i==len-1)\r\n            {\r\n                no+=columnTitle&#91;i]-'A'+1;\r\n            }else\r\n            {\r\n                no=no*26+(columnTitle&#91;i]-'A'+1)*26;\r\n            }\r\n        }\r\n        return no;\r\n    }\r\n};<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a26\u8fdb\u5236<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2130"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2130"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}