{"id":116011,"date":"2026-10-20T15:40:41","date_gmt":"2026-10-20T07:40:41","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/116011.html"},"modified":"2026-10-20T15:40:41","modified_gmt":"2026-10-20T07:40:41","slug":"deepseek-leetcode-394-%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%a7%a3%e7%a0%81-java%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/116011.html","title":{"rendered":"DeepSeek    LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0"},"content":{"rendered":"<p>LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 &#8211; Java \u5b9e\u73b0<\/p>\n<p>\u9898\u76ee\u56de\u987e<\/p>\n<p>\u7ed9\u5b9a\u7f16\u7801\u5b57\u7b26\u4e32&#xff0c;\u89c4\u5219\u4e3a k[encoded_string]&#xff0c;\u8868\u793a\u65b9\u62ec\u53f7\u5185\u7684\u5b57\u7b26\u4e32\u91cd\u590d k \u6b21\u3002\u53ef\u5d4c\u5957\u3002\u8fd4\u56de\u89e3\u7801\u540e\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;\u201c3[a2[c]]\u201d \u2192 \u201caccaccacc\u201d\u3002<\/p>\n<p>\u89e3\u6cd5\u4e00&#xff1a;\u53cc\u6808&#xff08;\u63a8\u8350&#xff0c;\u6700\u76f4\u89c2&#xff09;<\/p>\n<p>\u7528\u4e24\u4e2a\u6808\u5206\u522b\u4fdd\u5b58\u91cd\u590d\u6b21\u6570\u548c\u8fdb\u5165\u62ec\u53f7\u524d\u7684\u5df2\u62fc\u63a5\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u904d\u5386\u6bcf\u4e2a\u5b57\u7b26&#xff1a;<\/p>\n<p>\u5b57\u7b26 \u64cd\u4f5c<br \/>\n\u6570\u5b57 \u7d2f\u79ef\u6210\u591a\u4f4d\u6570\u5b57 num<br \/>\n[ \u5c06 num \u548c res \u5165\u6808&#xff0c;\u91cd\u7f6e num&#061;0\u3001res&#061;\u201c\u201d<br \/>\n] \u5f39\u51fa count \u548c prev&#xff0c;res &#061; prev &#043; res.repeat(count)<br \/>\n\u5b57\u6bcd res &#043;&#061; c<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Solution<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token function\">decodeString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> s<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">Deque<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">Integer<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> countStack <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">ArrayDeque<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\">Deque<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> strStack <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">ArrayDeque<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\">StringBuilder<\/span> res <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">StringBuilder<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">char<\/span> c <span class=\"token operator\">:<\/span> s<span class=\"token punctuation\">.<\/span><span class=\"token function\">toCharArray<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Character<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">isDigit<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                num <span class=\"token operator\">&#061;<\/span> num <span class=\"token operator\">*<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>        <span class=\"token comment\">\/\/ \u5904\u7406\u591a\u4f4d\u6570\u5b57<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token char\">&#039;[&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                countStack<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>num<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/\/ \u4fdd\u5b58\u91cd\u590d\u6b21\u6570<\/span><br \/>\n                strStack<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>res<span class=\"token punctuation\">.<\/span><span class=\"token function\">toString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u4fdd\u5b58\u5916\u5c42\u5df2\u62fc\u597d\u7684\u4e32<\/span><br \/>\n                num <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                res<span class=\"token punctuation\">.<\/span><span class=\"token function\">setLength<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                  <span class=\"token comment\">\/\/ \u91cd\u7f6e&#xff0c;\u5f00\u59cb\u62fc\u62ec\u53f7\u5185<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token char\">&#039;]&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token keyword\">int<\/span> count <span class=\"token operator\">&#061;<\/span> countStack<span class=\"token punctuation\">.<\/span><span class=\"token function\">pop<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token class-name\">StringBuilder<\/span> tmp <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">StringBuilder<\/span><span class=\"token punctuation\">(<\/span>strStack<span class=\"token punctuation\">.<\/span><span class=\"token function\">pop<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> count<span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                    tmp<span class=\"token punctuation\">.<\/span><span class=\"token function\">append<\/span><span class=\"token punctuation\">(<\/span>res<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token punctuation\">}<\/span><br \/>\n                res <span class=\"token operator\">&#061;<\/span> tmp<span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                res<span class=\"token punctuation\">.<\/span><span class=\"token function\">append<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                     <span class=\"token comment\">\/\/ \u666e\u901a\u5b57\u6bcd<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> res<span class=\"token punctuation\">.<\/span><span class=\"token function\">toString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u89e3\u6cd5\u4e8c&#xff1a;\u9012\u5f52&#xff08;\u81ea\u9876\u5411\u4e0b\u89e3\u6790&#xff09;<\/p>\n<p>\u9047\u5230 [ \u5c31\u9012\u5f52\u89e3\u6790\u5b50\u4e32&#xff0c;\u8fd4\u56de\u540e\u6309\u6b21\u6570\u62fc\u63a5&#xff0c;\u5e76\u7ee7\u7eed\u4ece\u53f3\u62ec\u53f7\u4e4b\u540e\u5904\u7406\u3002<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Solution<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5168\u5c40\u6307\u9488<\/span><\/p>\n<p>    <span class=\"token keyword\">public<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token function\">decodeString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> s<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">StringBuilder<\/span> res <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">StringBuilder<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span>i <span class=\"token operator\">&lt;<\/span> s<span class=\"token punctuation\">.<\/span><span class=\"token function\">length<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">char<\/span> c <span class=\"token operator\">&#061;<\/span> s<span class=\"token punctuation\">.<\/span><span class=\"token function\">charAt<\/span><span class=\"token punctuation\">(<\/span>i<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Character<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">isDigit<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                num <span class=\"token operator\">&#061;<\/span> num <span class=\"token operator\">*<\/span> <span class=\"token number\">10<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token char\">&#039;[&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span>                                <span class=\"token comment\">\/\/ \u8df3\u8fc7 &#039;[&#039;<\/span><br \/>\n                <span class=\"token class-name\">String<\/span> inner <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">decodeString<\/span><span class=\"token punctuation\">(<\/span>s<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u9012\u5f52\u89e3\u6790\u62ec\u53f7\u5185<\/span><br \/>\n                i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span>                                <span class=\"token comment\">\/\/ \u8df3\u8fc7 &#039;]&#039;<\/span><br \/>\n                <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> k <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> k <span class=\"token operator\">&lt;<\/span> num<span class=\"token punctuation\">;<\/span> k<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                    res<span class=\"token punctuation\">.<\/span><span class=\"token function\">append<\/span><span class=\"token punctuation\">(<\/span>inner<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                <span class=\"token punctuation\">}<\/span><br \/>\n                num <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token char\">&#039;]&#039;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token keyword\">return<\/span> res<span class=\"token punctuation\">.<\/span><span class=\"token function\">toString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>              <span class=\"token comment\">\/\/ \u9047\u5230\u53f3\u62ec\u53f7&#xff0c;\u8fd4\u56de\u7ed9\u4e0a\u5c42<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                res<span class=\"token punctuation\">.<\/span><span class=\"token function\">append<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> res<span class=\"token punctuation\">.<\/span><span class=\"token function\">toString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u89e3\u6cd5\u4e09&#xff1a;\u5355\u6808 &#043; \u8bb0\u5f55&#xff08;\u53ef\u9009&#xff09;<\/p>\n<p>\u4e5f\u53ef\u4ee5\u53ea\u7528\u4e00\u4e2a\u6808\u5b58&#034;\u6b21\u6570 \u548c \u5b57\u7b26\u4e32&#034;\u7684\u914d\u5bf9\u5bf9\u8c61&#xff0c;\u4f46\u53cc\u6808\u66f4\u6e05\u6670&#xff0c;\u8fd9\u91cc\u7565\u3002<\/p>\n<p>\u5173\u952e\u70b9<\/p>\n<li>\u591a\u4f4d\u6570\u5b57&#xff1a;num &#061; num * 10 &#043; (c &#8211; \u20180\u2019)&#xff0c;\u4e0d\u80fd\u53ea\u5904\u7406\u4e2a\u4f4d&#xff08;\u5982 \u201c12[ab]\u201d&#xff09;\u3002<\/li>\n<li>[ \u65f6\u4fdd\u5b58\u5916\u5c42\u72b6\u6001&#xff1a;\u5165\u6808\u7684\u662f&#034;\u6b64\u523b\u5df2\u7ecf\u62fc\u597d\u7684 res&#034;&#xff0c;\u4e0d\u662f\u7a7a\u4e32&#xff0c;\u8fd9\u6837 ] \u65f6\u53ef\u76f4\u63a5 prev &#043; repeated\u3002<\/li>\n<li>\u5d4c\u5957\u81ea\u7136\u6210\u7acb&#xff1a;\u56e0\u4e3a\u5185\u5c42 [ \u4f1a\u5148\u5165\u6808\u3001] \u5148\u51fa\u6808&#xff0c;\u7b26\u5408\u6808\u7684 LIFO \u8bed\u4e49\u3002<\/li>\n<li>StringBuilder.repeat \u9700 Java 11&#043;&#xff1b;\u4e3a\u517c\u5bb9\u53ef\u7528 for \u5faa\u73af&#xff08;\u4e0a\u9762\u89e3\u6cd5\u4e00\u5df2\u7528\u5faa\u73af&#xff09;\u3002<\/li>\n<p>\u590d\u6742\u5ea6\u5206\u6790<\/p>\n<p>\u00b7 \u65f6\u95f4\u590d\u6742\u5ea6&#xff1a;O(S)&#xff0c;S \u4e3a\u89e3\u7801\u540e\u5b57\u7b26\u4e32\u957f\u5ea6&#xff08;\u6bcf\u4e2a\u5b57\u7b26\u7684\u751f\u6210\u662f\u5fc5\u8981\u7684&#xff09;\u3002<br \/>\n\u00b7 \u7a7a\u95f4\u590d\u6742\u5ea6&#xff1a;O(S)&#xff0c;\u6808\u4e0e\u7ed3\u679c\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u793a\u4f8b\u9a8c\u8bc1<\/p>\n<p>s &#061; &#034;3[a2[c]]&#034;<\/p>\n<p>c&#061;&#039;3&#039; num&#061;3<br \/>\nc&#061;&#039;[&#039; push(3,&#034;&#034;); num&#061;0, res&#061;&#034;&#034;<br \/>\nc&#061;&#039;a&#039; res&#061;&#034;a&#034;<br \/>\nc&#061;&#039;2&#039; num&#061;2<br \/>\nc&#061;&#039;[&#039; push(2,&#034;a&#034;); num&#061;0, res&#061;&#034;&#034;<br \/>\nc&#061;&#039;c&#039; res&#061;&#034;c&#034;<br \/>\nc&#061;&#039;]&#039; count&#061;2 prev&#061;&#034;a&#034; -&gt; res &#061; &#034;a&#034;&#043;&#034;c&#034;*2 &#061; &#034;acc&#034;<br \/>\nc&#061;&#039;]&#039; count&#061;3 prev&#061;&#034;&#034;  -&gt; res &#061; &#034;&#034; &#043; &#034;acc&#034;*3 &#061; &#034;accaccacc&#034; \u2713<\/p>\n<p>\u89e3\u6cd5\u4e00\u5728\u5de5\u7a0b\u4e0a\u6700\u7a33\u5065&#xff0c;\u89e3\u6cd5\u4e8c\u4ee3\u7801\u66f4\u77ed&#xff0c;\u6309\u9700\u9009\u7528\u5373\u53ef\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020074038-6ad71af67cc66.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 &#8211; Java \u5b9e\u73b0<br \/>\n\u9898\u76ee\u56de\u987e<br \/>\n\u7ed9\u5b9a\u7f16\u7801\u5b57\u7b26\u4e32&#xff0c;\u89c4\u5219\u4e3a k[encoded_string]&#xff0c;\u8868\u793a\u65b9\u62ec\u53f7\u5185\u7684\u5b57\u7b26\u4e32\u91cd\u590d k \u6b21\u3002\u53ef\u5d4c\u5957\u3002\u8fd4\u56de\u89e3\u7801\u540e\u7684\u5b57\u7b26\u4e32\u3002<br \/>\n\u4f8b\u5982&#xff1a;\u201c3[a2[c]]\u201d \u2192 \u201caccaccacc\u201d\u3002<br \/>\n\u89e3\u6cd5\u4e00&#xff1a;\u53cc\u6808&#xff08;\u63a8\u8350&#xff0c;\u6700\u76f4\u89c2&#xff09;<br \/>\n\u7528\u4e24\u4e2a\u6808\u5206\u522b\u4fdd\u5b58\u91cd\u590d\u6b21\u6570\u548c\u8fdb\u5165\u62ec\u53f7\u524d\u7684\u5df2\u62fc\u63a5\u5b57\u7b26\u4e32\u3002<br \/>\n\u904d\u5386\u6bcf\u4e2a\u5b57\u7b26&#xff1a;<br \/>\n\u5b57\u7b26 \u64cd\u4f5c<br \/>\n\u6570\u5b57<\/p>\n","protected":false},"author":2,"featured_media":116010,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,2692,292,1813,427],"topic":[],"class_list":["post-116011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-leetcode","tag-292","tag-1813","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>DeepSeek  LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/116011.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DeepSeek  LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 - Java \u5b9e\u73b0 \u9898\u76ee\u56de\u987e \u7ed9\u5b9a\u7f16\u7801\u5b57\u7b26\u4e32&#xff0c;\u89c4\u5219\u4e3a k[encoded_string]&#xff0c;\u8868\u793a\u65b9\u62ec\u53f7\u5185\u7684\u5b57\u7b26\u4e32\u91cd\u590d k \u6b21\u3002\u53ef\u5d4c\u5957\u3002\u8fd4\u56de\u89e3\u7801\u540e\u7684\u5b57\u7b26\u4e32\u3002 \u4f8b\u5982&#xff1a;\u201c3[a2[c]]\u201d \u2192 \u201caccaccacc\u201d\u3002 \u89e3\u6cd5\u4e00&#xff1a;\u53cc\u6808&#xff08;\u63a8\u8350&#xff0c;\u6700\u76f4\u89c2&#xff09; \u7528\u4e24\u4e2a\u6808\u5206\u522b\u4fdd\u5b58\u91cd\u590d\u6b21\u6570\u548c\u8fdb\u5165\u62ec\u53f7\u524d\u7684\u5df2\u62fc\u63a5\u5b57\u7b26\u4e32\u3002 \u904d\u5386\u6bcf\u4e2a\u5b57\u7b26&#xff1a; \u5b57\u7b26 \u64cd\u4f5c \u6570\u5b57\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/116011.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-20T07:40:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020074038-6ad71af67cc66.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/116011.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/116011.html\",\"name\":\"DeepSeek LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-20T07:40:41+00:00\",\"dateModified\":\"2026-10-20T07:40:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/116011.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/116011.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/116011.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DeepSeek LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DeepSeek  LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/116011.html","og_locale":"zh_CN","og_type":"article","og_title":"DeepSeek  LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 - Java \u5b9e\u73b0 \u9898\u76ee\u56de\u987e \u7ed9\u5b9a\u7f16\u7801\u5b57\u7b26\u4e32&#xff0c;\u89c4\u5219\u4e3a k[encoded_string]&#xff0c;\u8868\u793a\u65b9\u62ec\u53f7\u5185\u7684\u5b57\u7b26\u4e32\u91cd\u590d k \u6b21\u3002\u53ef\u5d4c\u5957\u3002\u8fd4\u56de\u89e3\u7801\u540e\u7684\u5b57\u7b26\u4e32\u3002 \u4f8b\u5982&#xff1a;\u201c3[a2[c]]\u201d \u2192 \u201caccaccacc\u201d\u3002 \u89e3\u6cd5\u4e00&#xff1a;\u53cc\u6808&#xff08;\u63a8\u8350&#xff0c;\u6700\u76f4\u89c2&#xff09; \u7528\u4e24\u4e2a\u6808\u5206\u522b\u4fdd\u5b58\u91cd\u590d\u6b21\u6570\u548c\u8fdb\u5165\u62ec\u53f7\u524d\u7684\u5df2\u62fc\u63a5\u5b57\u7b26\u4e32\u3002 \u904d\u5386\u6bcf\u4e2a\u5b57\u7b26&#xff1a; \u5b57\u7b26 \u64cd\u4f5c \u6570\u5b57","og_url":"https:\/\/www.wsisp.com\/helps\/116011.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-20T07:40:41+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020074038-6ad71af67cc66.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/116011.html","url":"https:\/\/www.wsisp.com\/helps\/116011.html","name":"DeepSeek LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-20T07:40:41+00:00","dateModified":"2026-10-20T07:40:41+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/116011.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/116011.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/116011.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"DeepSeek LeetCode 394. \u5b57\u7b26\u4e32\u89e3\u7801 Java\u5b9e\u73b0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/116011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=116011"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/116011\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/116010"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=116011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=116011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=116011"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=116011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}