We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Abbreviation

Abbreviation

Problem
Submissions
Leaderboard
Discussions
Editorial
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Abbreviation
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

You can perform the following operations on the string, :

  1. Capitalize zero or more of 's lowercase letters.
  2. Delete all of the remaining lowercase letters in .

Given two strings, and , determine if it's possible to make equal to as described. If so, print YES on a new line. Otherwise, print NO.

For example, given and , in we can convert and delete to match . If and , matching is not possible because letters may only be capitalized or discarded, not changed.

Function Description

Complete the function in the editor below. It must return either or .

abbreviation has the following parameter(s):

  • a: the string to modify
  • b: the string to match

Input Format

The first line contains a single integer , the number of queries.

Each of the next pairs of lines is as follows:
- The first line of each query contains a single string, .
- The second line of each query contains a single string, .

Constraints

  • String consists only of uppercase and lowercase English letters, ascii[A-Za-z].
  • String consists only of uppercase English letters, ascii[A-Z].

Output Format

For each query, print YES on a new line if it's possible to make string equal to string . Otherwise, print NO.

Sample Input

1
daBcd
ABC

Sample Output

YES

Explanation

image

We have daBcd and ABC. We perform the following operation:

  1. Capitalize the letters a and c in so that dABCd.
  2. Delete all the remaining lowercase letters in so that ABC.

Because we were able to successfully convert to , we print YES on a new line.

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy