This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Solution(array) { | |
const dp = new Array(array.length); | |
dp[0] = []; | |
dp[0][0] = 0; | |
dp[0][1] = array[0]; | |
let max = 0; | |
for (let i = 1; i < array.length; ++i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
有一个猜数字游戏,庄家预先写下一个四位数字(每位数字各不相同),玩家每次随机猜一个数字,庄家告知玩家猜对了几A几B(A代表数字和位置都相同,B代表包含该数字但位置不同,比如如果庄家写的是3514,玩家猜的是3165,庄家会回答1A2B),玩家继续猜,直到猜中为止。如果超过5轮没猜中,则玩家输,否则玩家赢。 | |
请为玩家设计一个猜数字的算法,确保玩家能够大概率胜。 | |
*/ | |
// 返回数字和位置都相同的个数 | |
const calcStrictIdentical = (target, input) => { | |
let count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$simsun-font-family: arial,\5b8b\4f53; | |
$yahei-font-family :"Microsoft YaHei",\5fae\8f6f\96c5\9ed1,arial,\5b8b\4f53; | |
body { | |
line-height: 1.5; | |
} | |
h1 { | |
font-size: 3em; |