Question: please let me know about the answer! Circular movement You are standing on a circular path. From your initial position, you can move either in

please let me know about the answer!  please let me know about the answer! Circular movement You are
standing on a circular path. From your initial position, you can move
either in a clockwise direction or in an anticlockwise direction but you
can move only along the circular path. Your movements are represented by
a string S. This string can consist of three different types of

Circular movement You are standing on a circular path. From your initial position, you can move either in a clockwise direction or in an anticlockwise direction but you can move only along the circular path. Your movements are represented by a string S. This string can consist of three different types of characters, each denoting a move as follows: - A: You move 1 unit in an anticlockwise direction - C. You move 1 unit in a clockwise direction - ?. You move 1 unit either in a clockwise or anticlockwise direction Task Determine the maximum distance from your initial position you can move in any direction. Example Assumption - S=ACPC Approach - If you replace? with C, you can move a 2 unit distance in a clockwise direction from initial position. Therefore the maximum distance is 3. Function description Complete the solve function provided in the editor. This function takes the following parameters and returns the answer. - S : Represents the input string Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). - The first line contains a single integer T that denotes the number of test cases. T also denotes the number of times you have to run the solve function on a different set of inputs. - The next T lines contain a string denoting S. Output format For each test case, print the maximum distance you can move from the initial position in any direction in a new line. Constraints 1T101S105 Code snippets (also called starter code/boilerplate code) This question has code snippets for C, CPP, Java, and Python. Sample input Sample output 1 5 AAAA? C Explanation The first line contains the number of test cases, T=1. Explanation The first line contains the number of test cases, T=1. The first test case Given - S=AAAAPC Approach - If you replace ? with A, you can move a 5 unit distance in an anticlockwise direction. Therefore the maximum distance is 5 . The following test cases are the actual test cases of this question that may be used to evaluate your submission. Sample output 2

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!