Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

these bellow 2 pictures are one question.
I need the code using C++ language image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students explore these related Databases questions