Two substrings

Level EASY

You are given a string s. Your task is to determine, if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). Print "yes" or "no".

The string s contains uppercase Latin letters only.

Input format :
Line 1 : String s
Output format :
yes or no
Constraints :

1 <= n (Length of String s) <= 10^5

Sample Input 1 :
ABA
Sample Output 1 :
no
Sample Input 2 :
BACFAB
Sample Output 2 :
yes
Sample Input 3 :
AXBYBXA
Sample Output 3 :
no

Comments

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius