Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

these bellow 2 pictures are 1 question. please solve it You will be given a string of characters between 'a' to 'j' and a list

these bellow 2 pictures are 1 question. please solve it 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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Who is your key public?

Answered: 1 week ago