// 判断一个字符串是否为驼峰字符串, judge('ByteDance','BD') -> true judge('Bytedance','BD') -> false
// 双指针
function isValid(str, judge) {
judge = judge.toUpperCase()
let j = 0;
for (let i = 0; i < str.length; i++) {
if (str[i] === judge[j] && j < judge.length) j++;
}
return j === judge.length;
}
console.log(isValid("Bytedance", "BD"));
console.log(isValid("ByteDance", "BD"));