Question: Problem statementSend feedbackGojo has 2 weapons RED and BLUE. His attacks are given to you in a string. He can choose any substring which is

Problem statementSend feedbackGojo has 2 weapons RED and BLUE. His attacks are given to you in a string. He can choose any substring which is not empty and if it has equal number of RED and BLUE attacks, he can combine them and perform PURPLE ATTACK.Your task is to determine if it is possible to perform the PURPLE attack.Example:'S'="RRBRBBRR"He can choose the substring "RBBR" and as there are 2 RED attacks and 2BLUE attacks, he can combine and perform the PURPLE attack.Detailed explanation (Input/output format, Notes. Images )Constraints :1 c=<=101c= IS|<=101.3, where S is the string of attacks.It is guaranteed that the sum of IS over all test cases won't exceed '10^5'.Time Limit 1 secondSample Input 1:RBRRBBRSample Output 1:YESNOExplanation Of Sample Input 1:Explanation Of Sample Input 1:For test case 1:He can choose the substring "RBRRBB". As there are 3 RED attacks and 3BLUE attacks, he can combine and perform the PURPLE attack.For test case 2:There is no substring where the number of RED and BLUE attacks are equal:
Java code using
Public static boolean purple(String s){} method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!