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 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:SRRBRBBRRHe can choose the substring RBBR and as there are RED attacks and BLUE attacks, he can combine and perform the PURPLE attack.Detailed explanation Inputoutput format, Notes. Images Constraints : cc IS where S is the string of attacks.It is guaranteed that the sum of IS over all test cases won't exceed Time Limit secondSample Input :RBRRBBRSample Output :YESNOExplanation Of Sample Input :Explanation Of Sample Input :For test case :He can choose the substring RBRRBB As there are RED attacks and BLUE attacks, he can combine and perform the PURPLE attack.For test case :There is no substring where the number of RED and BLUE attacks are equal:
Java code using
Public static boolean purpleString s method
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
