Your question is String A Before B. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A phData pipeline validation step receives a sequence containing only A and B labels. Return True if all A labels occur before all B labels. Return False if an A appears after any B.
The sequence may contain any number of consecutive labels, including only one label type. Solve the problem in one left-to-right pass without sorting or modifying the input.
Implement all_as_before_bs(labels).
labels, a string containing only uppercase characters A and B.True when the string has the form A*B*, where either group may be empty. Otherwise, return False.def all_as_before_bs(labels):