-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
括号内的空格或者其他分隔字符忽略 #1676
括号内的空格或者其他分隔字符忽略 #1676
Conversation
stack.push(i) | ||
} else if (str[i] === ')') { | ||
stack.pop() | ||
i + 1 === str.length && (result.push(str.slice(lastIdx, str.length))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
push的条件不应该是结束而是stack清空,以及可以用个数值表示,不用建立一个stack数组
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以及可以同时实现item.trim()
stack-- | ||
} | ||
// 非分隔字符添加 括号内的非空分隔字符添加 // Todo 清除括号内的空格 || (stack !== 0 && str[i] === ' ') | ||
if (str[i] !== char || (str[i] === char && stack !== 0 && char !== ' ')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
条件改为stack!==0 || (str[i] !== char && str[i] !== ' ')
No description provided.