Question: these bellow 2 pictures are one question. I need the code using C++ language You will be given a string of characters between 'a' to

You will be given a string of characters between 'a' to 'j' and a list of M pair of characters, u and v. You can perform the following operation First you have to choose a pair of characters, u and from the given list. Then, you can replace a character u in the given string with v. After the replacement the new string will be your given string. You have to output whether you can rearrange the characters in the given string in non-decreasing order by performing this operation any number of times. Input First line contains an integer T denotes the number of test cases. Each test case starts with a string of length N. Following line contains an integer M denotes the number of pairs of characters. Each of the following lines contain two characters u and v. Constraints: 1ST 100 1 SNS 10000 OSM 500 'a'su, vs Output For each test case, you have to print 'YES' (without quotes) if the given string can be rearranged in non- decreasing order, otherwise print 'NO'. Sample Input Output 3 adb Copy NO YES YES 0 abed 2 da ed abed 2 da 09
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
