Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

these bellow 2 pictures are one question. I need the code so please solve with coding You will be given a string of characters between

these bellow 2 pictures are one question. I need the code so please solve with coding 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

Step: 3

blur-text-image

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

Differentiate (with respect to t or x): y = sin 3 t 2

Answered: 1 week ago

Question

Presentations Approaches to Conveying Information

Answered: 1 week ago