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

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

How to pass parameters in webhook?

MySQL Multi Source Master Slave Replication using GTID