STELLAPPS On-Campus OA (2021) | Problem Check if All A's Appear Before All B's

Question · Posted Jun 2026

Problem Statement Given a string s consisting only of characters 'a' and 'b', return true if every 'a' appears before every 'b'. Otherwise, return false. Example Input s = "aaabbb" Output true Explanation All 'a' characters occur before any 'b'. Constraints 1 <= s.length <= 100 s contains only 'a' and 'b'

The full answer & interview discussion are available to premium members.

Log in Create a free account