Check if All A's Appears Before All B's(LeetCode 2124):

Problem