Given a String of three Colours(G, B, Y) as input, the task is to print the resultant combined colour formed according to the rule given below:
// Rules for colour combination Blue(B) * Green(G) = Yellow(Y) Yellow(Y) * Blue(B) = Green(G) Green(G) * Yellow(Y) = Blue(B)
Input: str = "GBYGB" Output B Input: str = "BYB" Output Y
Approach: This problem can be solved as follows:
- Get the input string.
- Compare each alphabet with its adjacent characters.
- Use the above condition to determine the combination.
- print the output combination.
Below is the implementation of the above approach:
- Shortest possible combination of two strings
- Count number of strings (made of R, G and B) using given combination
- Python | Print all string combination from given numbers
- Find the value of N when F(N) = f(a)+f(b) where a+b is the minimum possible and a*b = N
- Find the nth term of the given series
- Find Nth term of the series 1, 6, 18, 40, 75, ....
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Find substrings that contain all vowels
- Find elements of an Array which are Odd and Even using STL in C++
- Find sub-string with given power
- Find the maximum possible value of a[i] % a[j] over all pairs of i and j
- Program to find the initials of a name.
- How to find the sum of elements of an Array using STL in C++?
- Find the sum of the number of divisors
- Find Pth term of a GP if Mth and Nth terms are given
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.