Question: An alternating string is a string in which no two consecutive characters are same. Ramesh loves alternating strings. So, on his birthday, he recieves x

An alternating string is a string in which no two consecutive characters are same. Ramesh loves alternating strings. So, on his birthday, he recieves x amount of letter 'a', y amount of letter 'b', and z amount of string "ab" as gift. Now, he wants to assemble the largest alternating string using this birthday gift. Write a program to print the length of the longest such string.

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!