Question: You are given a string S which consists of only two characters 'a'and 'b' The value of X is the maximum distance between any

You are given a string S which consists of only two characters

You are given a string S which consists of only two characters 'a'and 'b' The value of X is the maximum distance between any two 'a'in a string. The value of Yis the minimum distance between any two 'b'in a string. Distance between two characters is defined as //-// where i is the index of the first character and/ is the index of the second character in the string. Find the value of X+Y. Note Consider 0-based indexing of string. It is guaranteed that at least two occurrences of "a" and at least two occurrences of "b" are present in the string. Function Description In the provided code snippet, implement the provided addingNumbers (...) method using the variables to print the value of X+Y. You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE". There will be multiple test cases running so the Input and Output should match exactly as provided. The base Output variable result is set to a default value of -404 which can be modified. Additionally. you can add or remove these output variables.

Step by Step Solution

3.58 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Problem Analysis Given A string S with only a and b X maximum distance between any two a s Y minimum ... View full answer

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 Computer Engineering Questions!