Interview Questions/Coding/Guest List Reconstruction

Guest List Reconstruction

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Guest List Reconstruction

An event check has two official guest-name strings and one shuffled badge pile. The badge pile is valid only if it contains exactly all letters from both official names, with no missing letters and no extra letters. Letter order in the pile does not matter. Input Format: The first line contains t, the number of test cases. Each test case contains three strings: the first official name, the second official name, and the badge pile. Output Format: For each test case, print YES if the pile is valid, otherwise print NO.

Examples

Example 1
Input:
1
SANTACLAUS DEDMOROZ SANTAMOROZDEDCLAUS
Output:
YES

Explanation: The pile contains exactly the letters from SANTACLAUS and DEDMOROZ combined.

Approach hint

Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp