Wildcard Anagram
InterviewTime limit2sMemory limit512 MB
Given two equal-length strings, check whether the second is an anagram of the first after treating its asterisks as any letters.
- Level
Easy3 of 10
- Topics
- String, Hash map, Sorting, Implementation
- Solved
- No attempts yet
Problem
An anagram of a string is formed by rearranging the letters of the string. For example, the anagrams of aab are aab, aba, and baa.
A wildcard anagram of a string is an anagram of that string in which some letters have been replaced with an asterisk *. For example, *ab and *b* are wildcard anagrams of aab. Replacing no letter at all is allowed, so every anagram is also a wildcard anagram.
Given two strings, decide whether the second string is a wildcard anagram of the first string.
Input
The first line and the second line each contain one string, and both strings have the same length (). Every character on the first line is a lowercase letter. Every character on the second line is a lowercase letter or an asterisk *.
Output
Print A on one line if the string on the second line is a wildcard anagram of the string on the first line, and N otherwise.