{"id":114738,"date":"2026-10-10T00:32:49","date_gmt":"2026-10-09T16:32:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/114738.html"},"modified":"2026-10-10T00:32:49","modified_gmt":"2026-10-09T16:32:49","slug":"deepseek-leetcode-299-%e7%8c%9c%e6%95%b0%e5%ad%97%e6%b8%b8%e6%88%8f-java%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/114738.html","title":{"rendered":"DeepSeek    LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f Java\u5b9e\u73b0"},"content":{"rendered":"<p>LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f<\/p>\n<p>\u9898\u76ee\u5206\u6790<\/p>\n<p>\u7ed9\u5b9a secret \u548c guess \u4e24\u4e2a\u7b49\u957f\u5b57\u7b26\u4e32&#xff08;\u53ea\u542b\u6570\u5b57&#xff09;&#xff0c;\u9700\u8981\u7edf\u8ba1&#xff1a;<\/p>\n<p>\u00b7 Bulls&#xff08;A&#xff09;&#xff1a;\u6570\u5b57\u548c\u4f4d\u7f6e\u90fd\u6b63\u786e\u7684\u4e2a\u6570<br \/>\n\u00b7 Cows&#xff08;B&#xff09;&#xff1a;\u6570\u5b57\u6b63\u786e\u4f46\u4f4d\u7f6e\u4e0d\u5bf9\u7684\u4e2a\u6570<\/p>\n<p>\u5173\u952e\u70b9&#xff1a;\u4e24\u4e2a\u5b57\u7b26\u4e32\u90fd\u53ef\u80fd\u542b\u6709\u91cd\u590d\u6570\u5b57&#xff0c;\u6240\u4ee5 Cows \u53ea\u80fd\u901a\u8fc7\u300c\u9891\u6b21\u53d6\u6700\u5c0f\u300d\u6765\u8ba1\u7b97&#xff0c;\u4e0d\u80fd\u7b80\u5355\u7528\u96c6\u5408\u3002<\/p>\n<hr \/>\n<p>\u89e3\u6cd5\u4e00&#xff1a;\u4e24\u6b21\u904d\u5386&#xff08;\u63a8\u8350&#xff0c;\u6700\u76f4\u89c2&#xff09;<\/p>\n<p>\u601d\u8def&#xff1a;<\/p>\n<li>\u7b2c\u4e00\u904d\u904d\u5386&#xff1a;\u4f4d\u7f6e\u76f8\u540c\u7684\u8bb0\u4e3a bulls&#xff1b;\u4f4d\u7f6e\u4e0d\u540c\u7684\u5206\u522b\u7edf\u8ba1 secret \u548c guess \u4e2d\u6bcf\u4e2a\u6570\u5b57\u7684\u9891\u6b21\u3002<\/li>\n<li>\u7b2c\u4e8c\u904d&#xff1a;\u5bf9 0~9 \u6bcf\u4e2a\u6570\u5b57&#xff0c;cows &#043;&#061; min(secretCount[d], guessCount[d])&#xff0c;\u56e0\u4e3a\u4e00\u4e2a\u6570\u5b57\u6700\u591a\u53ea\u80fd\u5339\u914d\u4e24\u8fb9\u8f83\u5c11\u7684\u90a3\u4e2a\u6570\u91cf\u3002<\/li>\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\">getHint<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> secret<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">String<\/span> guess<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> secretCount <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> guessCount <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> bulls <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> cows <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\">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> secret<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> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">char<\/span> s <span class=\"token operator\">&#061;<\/span> secret<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\">char<\/span> g <span class=\"token operator\">&#061;<\/span> guess<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>s <span class=\"token operator\">&#061;&#061;<\/span> g<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                bulls<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 punctuation\">{<\/span><br \/>\n                secretCount<span class=\"token punctuation\">[<\/span>s <span class=\"token operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                guessCount<span class=\"token punctuation\">[<\/span>g <span class=\"token operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">]<\/span><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><\/p>\n<p>        <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> d <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span> d <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span> d<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            cows <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token class-name\">Math<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">min<\/span><span class=\"token punctuation\">(<\/span>secretCount<span class=\"token punctuation\">[<\/span>d<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> guessCount<span class=\"token punctuation\">[<\/span>d<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token keyword\">return<\/span> bulls <span class=\"token operator\">&#043;<\/span> <span class=\"token string\">&#034;A&#034;<\/span> <span class=\"token operator\">&#043;<\/span> cows <span class=\"token operator\">&#043;<\/span> <span class=\"token string\">&#034;B&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u590d\u6742\u5ea6&#xff1a;\u65f6\u95f4 O(n)&#xff0c;\u7a7a\u95f4 O(1)&#xff08;\u56fa\u5b9a 10 \u4e2a\u6876&#xff09;\u3002<\/p>\n<hr \/>\n<p>\u89e3\u6cd5\u4e8c&#xff1a;\u4e00\u6b21\u904d\u5386&#xff08;\u6280\u5de7\u6027\u5f3a&#xff09;<\/p>\n<p>\u601d\u8def&#xff1a;\u7528\u4e00\u4e2a count \u6570\u7ec4\u8868\u793a\u300csecret \u76f8\u5bf9 guess \u591a\u51fa\u6765\u7684\u6570\u5b57\u6570\u91cf\u300d\u3002<\/p>\n<p>\u00b7 count[d] &gt; 0&#xff1a;secret \u4e2d\u6570\u5b57 d \u591a\u51fa\u6765\u4e86&#xff0c;\u7b49\u7740\u540e\u9762 guess \u51fa\u73b0 d \u6765\u914d\u5bf9<br \/>\n\u00b7 count[d] &lt; 0&#xff1a;guess \u4e2d\u6570\u5b57 d \u591a\u51fa\u6765\u4e86&#xff0c;\u7b49\u7740\u540e\u9762 secret \u51fa\u73b0 d \u6765\u914d\u5bf9<\/p>\n<p>\u904d\u5386\u65f6&#xff0c;\u9047\u5230 s !&#061; g&#xff1a;<\/p>\n<p>\u00b7 \u82e5 count[s] &lt; 0&#xff0c;\u8bf4\u660e\u4e4b\u524d guess \u91cc\u6709\u591a\u4f59\u7684 s&#xff0c;\u73b0\u5728\u53ef\u4ee5\u914d\u5bf9 \u2192 cows&#043;&#043;<br \/>\n\u00b7 \u82e5 count[g] &gt; 0&#xff0c;\u8bf4\u660e\u4e4b\u524d secret \u91cc\u6709\u591a\u4f59\u7684 g&#xff0c;\u73b0\u5728\u53ef\u4ee5\u914d\u5bf9 \u2192 cows&#043;&#043;<br \/>\n\u00b7 \u66f4\u65b0 count[s]&#043;&#043;&#xff0c;count[g]\u2013<\/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\">getHint<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> secret<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">String<\/span> guess<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> count <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">int<\/span> bulls <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> cows <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\">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> secret<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> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token keyword\">int<\/span> s <span class=\"token operator\">&#061;<\/span> secret<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 operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">int<\/span> g <span class=\"token operator\">&#061;<\/span> guess<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 operator\">&#8211;<\/span> <span class=\"token char\">&#039;0&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>s <span class=\"token operator\">&#061;&#061;<\/span> g<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                bulls<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 punctuation\">{<\/span><br \/>\n                <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>count<span class=\"token punctuation\">[<\/span>s<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> cows<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ guess \u4e2d\u4e4b\u524d\u591a\u4e86 s&#xff0c;\u73b0\u5728\u914d\u4e0a<\/span><br \/>\n                <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>count<span class=\"token punctuation\">[<\/span>g<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> cows<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ secret \u4e2d\u4e4b\u524d\u591a\u4e86 g&#xff0c;\u73b0\u5728\u914d\u4e0a<\/span><br \/>\n                count<span class=\"token punctuation\">[<\/span>s<span class=\"token punctuation\">]<\/span><span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n                count<span class=\"token punctuation\">[<\/span>g<span class=\"token punctuation\">]<\/span><span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token keyword\">return<\/span> bulls <span class=\"token operator\">&#043;<\/span> <span class=\"token string\">&#034;A&#034;<\/span> <span class=\"token operator\">&#043;<\/span> cows <span class=\"token operator\">&#043;<\/span> <span class=\"token string\">&#034;B&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u590d\u6742\u5ea6&#xff1a;\u65f6\u95f4 O(n)&#xff0c;\u7a7a\u95f4 O(1)\u3002<\/p>\n<hr \/>\n<p>\u793a\u4f8b\u9a8c\u8bc1<\/p>\n<p>\u8f93\u5165: secret &#061; &#034;1807&#034;, guess &#061; &#034;7810&#034;<br \/>\n\u8f93\u51fa: &#034;1A3B&#034;<br \/>\n\u89e3\u91ca:<br \/>\n  1 \u4e2a\u516c\u725b (\u4f4d\u7f6e 1 \u7684 &#039;8&#039;)<br \/>\n  3 \u4e2a\u5976\u725b (&#039;0&#039;,&#039;1&#039;,&#039;7&#039; \u6570\u5b57\u5bf9\u4f46\u4f4d\u7f6e\u9519)<\/p>\n<p>\u8f93\u5165: secret &#061; &#034;1123&#034;, guess &#061; &#034;0111&#034;<br \/>\n\u8f93\u51fa: &#034;1A1B&#034;<br \/>\n\u89e3\u91ca:<br \/>\n  1 \u4e2a\u516c\u725b (\u4f4d\u7f6e 2 \u7684 &#039;1&#039; \u5728\u7d22\u5f15 1 \u5904\u5339\u914d)<br \/>\n  1 \u4e2a\u5976\u725b (secret \u5269\u4e0b\u7684 &#039;1&#039; \u548c guess \u7684 &#039;1&#039;)<br \/>\n  \u6ce8\u610f\u91cd\u590d\u6570\u5b57&#xff1a;secret \u6709 2 \u4e2a &#039;1&#039;&#xff0c;guess \u6709 3 \u4e2a &#039;1&#039;&#xff0c;\u53bb\u6389\u516c\u725b\u7684 1 \u4e2a\u540e&#xff0c;<br \/>\n  \u4e24\u8fb9\u5269\u4f59\u5404 1 \u4e2a\u548c 2 \u4e2a&#xff0c;\u53d6 min &#061; 1\u3002<\/p>\n<hr \/>\n<p>\u6613\u9519\u70b9\u63d0\u9192<\/p>\n<li>\u91cd\u590d\u6570\u5b57\u5fc5\u987b\u7528\u9891\u6b21\u7edf\u8ba1&#xff0c;\u4e0d\u80fd\u7528 Set \u53bb\u91cd\u3002<\/li>\n<li>Cows \u7edf\u8ba1\u65f6\u5fc5\u987b\u6392\u9664\u5df2\u7ecf\u7b97\u4f5c Bull \u7684\u4f4d\u7f6e&#xff08;\u89e3\u6cd5\u4e00\u4e2d\u5148\u5224\u65ad s &#061;&#061; g \u518d\u7edf\u8ba1&#xff09;\u3002<\/li>\n<li>\u8fd4\u56de\u683c\u5f0f\u662f \u201cxAyB\u201d&#xff0c;\u4e2d\u95f4\u662f\u5b57\u7b26\u4e32\u62fc\u63a5\u3002<\/li>\n<p>\u4e24\u79cd\u89e3\u6cd5\u90fd\u53ef AC&#xff0c;\u89e3\u6cd5\u4e00\u66f4\u6613\u7406\u89e3\u548c\u4e66\u5199&#xff0c;\u89e3\u6cd5\u4e8c\u66f4\u4f18\u96c5\u4f46\u9700\u8981\u7406\u89e3 count \u6570\u7ec4\u7684\u6b63\u8d1f\u542b\u4e49\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261009163246-6ac9172e7f90a.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f<br \/>\n\u9898\u76ee\u5206\u6790<br \/>\n\u7ed9\u5b9a secret \u548c guess \u4e24\u4e2a\u7b49\u957f\u5b57\u7b26\u4e32&#xff08;\u53ea\u542b\u6570\u5b57&#xff09;&#xff0c;\u9700\u8981\u7edf\u8ba1&#xff1a;<br \/>\n\u00b7 Bulls&#xff08;A&#xff09;&#xff1a;\u6570\u5b57\u548c\u4f4d\u7f6e\u90fd\u6b63\u786e\u7684\u4e2a\u6570<br \/>\n\u00b7 Cows&#xff08;B&#xff09;&#xff1a;\u6570\u5b57\u6b63\u786e\u4f46\u4f4d\u7f6e\u4e0d\u5bf9\u7684\u4e2a\u6570<br \/>\n\u5173\u952e\u70b9&#xff1a;\u4e24\u4e2a\u5b57\u7b26\u4e32\u90fd\u53ef\u80fd\u542b\u6709\u91cd\u590d\u6570\u5b57&#xff0c;\u6240\u4ee5 Cows \u53ea\u80fd\u901a\u8fc7\u300c\u9891\u6b21\u53d6\u6700\u5c0f\u300d\u6765\u8ba1\u7b97&amp;#xff0<\/p>\n","protected":false},"author":2,"featured_media":114737,"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-114738","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 299. \u731c\u6570\u5b57\u6e38\u620f 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\/114738.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DeepSeek  LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f \u9898\u76ee\u5206\u6790 \u7ed9\u5b9a secret \u548c guess \u4e24\u4e2a\u7b49\u957f\u5b57\u7b26\u4e32&#xff08;\u53ea\u542b\u6570\u5b57&#xff09;&#xff0c;\u9700\u8981\u7edf\u8ba1&#xff1a; \u00b7 Bulls&#xff08;A&#xff09;&#xff1a;\u6570\u5b57\u548c\u4f4d\u7f6e\u90fd\u6b63\u786e\u7684\u4e2a\u6570 \u00b7 Cows&#xff08;B&#xff09;&#xff1a;\u6570\u5b57\u6b63\u786e\u4f46\u4f4d\u7f6e\u4e0d\u5bf9\u7684\u4e2a\u6570 \u5173\u952e\u70b9&#xff1a;\u4e24\u4e2a\u5b57\u7b26\u4e32\u90fd\u53ef\u80fd\u542b\u6709\u91cd\u590d\u6570\u5b57&#xff0c;\u6240\u4ee5 Cows \u53ea\u80fd\u901a\u8fc7\u300c\u9891\u6b21\u53d6\u6700\u5c0f\u300d\u6765\u8ba1\u7b97&amp;#xff0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/114738.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-09T16:32:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261009163246-6ac9172e7f90a.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\/114738.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/114738.html\",\"name\":\"DeepSeek LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-09T16:32:49+00:00\",\"dateModified\":\"2026-10-09T16:32:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/114738.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/114738.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/114738.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DeepSeek LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f 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 299. \u731c\u6570\u5b57\u6e38\u620f 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\/114738.html","og_locale":"zh_CN","og_type":"article","og_title":"DeepSeek  LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f \u9898\u76ee\u5206\u6790 \u7ed9\u5b9a secret \u548c guess \u4e24\u4e2a\u7b49\u957f\u5b57\u7b26\u4e32&#xff08;\u53ea\u542b\u6570\u5b57&#xff09;&#xff0c;\u9700\u8981\u7edf\u8ba1&#xff1a; \u00b7 Bulls&#xff08;A&#xff09;&#xff1a;\u6570\u5b57\u548c\u4f4d\u7f6e\u90fd\u6b63\u786e\u7684\u4e2a\u6570 \u00b7 Cows&#xff08;B&#xff09;&#xff1a;\u6570\u5b57\u6b63\u786e\u4f46\u4f4d\u7f6e\u4e0d\u5bf9\u7684\u4e2a\u6570 \u5173\u952e\u70b9&#xff1a;\u4e24\u4e2a\u5b57\u7b26\u4e32\u90fd\u53ef\u80fd\u542b\u6709\u91cd\u590d\u6570\u5b57&#xff0c;\u6240\u4ee5 Cows \u53ea\u80fd\u901a\u8fc7\u300c\u9891\u6b21\u53d6\u6700\u5c0f\u300d\u6765\u8ba1\u7b97&amp;#xff0","og_url":"https:\/\/www.wsisp.com\/helps\/114738.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-09T16:32:49+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261009163246-6ac9172e7f90a.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\/114738.html","url":"https:\/\/www.wsisp.com\/helps\/114738.html","name":"DeepSeek LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f Java\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-09T16:32:49+00:00","dateModified":"2026-10-09T16:32:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/114738.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/114738.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/114738.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"DeepSeek LeetCode 299. \u731c\u6570\u5b57\u6e38\u620f 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\/114738","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=114738"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/114738\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/114737"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=114738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=114738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=114738"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=114738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}