https://bigfrontend.dev/zh/problem/implement-Object.is
function is(a, b) {
if (a === b) {
return a !== 0 || 1 / a === 1 / b;
}
return a !== a && b !== b;
}
https://leetcode-cn.com/problems/decode-string/
function decodeString(s: string): string {
let result = '';
let prevNum = 0;
const numStack: number[] = [];
const strStack: string[] = [];
for (const char of s) {
const c = Number.parseInt(char);
if (Number.isInteger(c)) {
prevNum = prevNum * 10 + c;
} else if (char === '[') {
numStack.push(prevNum);
strStack.push(result);
result = '';
prevNum = 0;
} else if (char === ']') {
const repeatTimes = numStack.pop();
result = strStack.pop() + result.repeat(repeatTimes);
} else {
result += char;
}
}
return result;
};