ValidString
https://leetcode.com/discuss/interview-question/1557009/amazon-online-coding-assessment-sde-2
Last updated
Was this helpful?
https://leetcode.com/discuss/interview-question/1557009/amazon-online-coding-assessment-sde-2
Last updated
Was this helpful?
There are 3 rules for a valid string:
An empty string is valid
You can add same character to a valid string X, and create another valid string yXy
You can concatenate two valid strings X and Y, so XY will also be valid.
Ex: vv, xbbx, bbccdd, xyffyxdd are all valid..
(It's essentially the valid parentheses question but with alphabets instead of parentheses . This can be solve in O(n)
with a stack.)
Using stack -