第一题没写出来还耗了四十分钟
第二题忘了用map只过了50%(猪脑过载)
第三题丑陋的dp,但是a了
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
(async () => {
// Write your code here
let [n, m] = (await readline()).split(" ").map((v) => v * 1);
// console.log(n, m);
let path = Array(n)
.fill()
.map(() => Array(m).fill(0));
let arr = [];
for (let i = 0; i < n; i++) {
arr.push((await readline()).split(""));
}
path[0][0] = 1;
for (let i = 1; i < n; i++) {
if (arr[i][0] === "#") break;
let num = 0;
for (let j = i; j > 0; j--) {
num += path[i - j][0];
}
path[i][0] = num;
}
for (let i = 1; i < m; i++) {
if (arr[0][i] === "#") break;
let num = 0;
for (let j = i; j > 0; j--) {
num += path[0][i - j];
}
path[0][i] = num;
}
for (let i = 1; i < n; i++) {
for (let j = 1; j < m; j++) {
let row = i;
let col = j;
let sum = 0;
while (row >= 0 && arr[row][col] !== "#") {
sum += path[row][col];
row--;
}
row = i;
col = j;
while (col >= 0 && arr[row][col] !== "#") {
sum += path[row][col];
col--;
}
path[i][j] = sum%10000007;
}
}
// console.log(arr);
// console.log(path);
console.log(path[n - 1][m - 1]);
})();
第四题一样时间不够直接返回a-b过60%
第五题正则
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
(async () => {
// Write your code here
let pattern = await readline();
let ts = (await readline()) * 1;
const date = new Date(ts);
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const tokens = {
YYYY: year,
YY: year.toString().slice(-2),
M: month,
MM: month.toString().padStart(2, "0"),
D: day,
DD: day.toString().padStart(2, "0"),
};
cache = pattern.match(/\[(.*?)\]/g);
console.log(cache);
pattern = pattern
.replace(/\[(.*?)\]/g, "#")
.replace(/YYYY/g, tokens.YYYY)
.replace(/YY/g, tokens.YYYY)
.replace(/MM/g, tokens.MM)
.replace(/M/g, tokens.M)
.replace(/DD/g, tokens.DD)
.replace(/D/g, tokens.D)
.replace(/#/g, () => cache.shift().slice(1,-1));
console.log(pattern);
})();
太杠第一题了白丢0.9题,我是猪卵大伙都a了多少
#软件开发2023笔面经##前端##我的实习求职记录#