You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function _firter(s) {
let stack = [];
for (let i = 0; i < s.length; i ++) {
if(s[i] === 'b') continue;
if (stack.length) {
if (s[i] === 'c' && stack[stack.length - 1] === 'a') {
stack.pop();
continue;
}
}
stack.push(s[i]);
}
return stack.join('');
}
let a = 'aaabbccc';
let r = _firter(a);
console.log(r);
The text was updated successfully, but these errors were encountered:
对输入的字符串,去除其中的字符'b'以及连续出现的'a'和'c'
例如:
'aacbd' -> 'ad'
'aabcd' -> 'ad'
'aaabbccc' -> ''
The text was updated successfully, but these errors were encountered: