567. Valid Word
0
Medium
Given a string s, determine if it is valid.
A string s is considered valid if, starting with an empty string t = "", you can transform t into s by repeatedly inserting the string "abc" at any position in t. In other words, t can be split into two parts, t_left and t_right, such that t = t_left + "abc" + t_right. It is important to note that t_left and t_right can be empty.
Input Format
String
Output Format
Print true if s is a valid string, otherwise print false.
Example
Input
aabcbc
Output
true
Constraints
1 <= s.length <= 2 * 10^4
s consists of letters 'a', 'b', and 'c'
Loading...
View Submissions
Console