Big Integers
InterviewTime limit2sMemory limit2048 MB
For each pair of base 62 strings, check whether lexicographic order matches numeric order and print YES or NO.
- Level
Easy3 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Nick is preparing a problem for a programming contest about comparing big integers. Integers are written in base 62, with the digits 0 through 9 representing values 0 through 9, the lowercase letters a through z representing values 10 through 35, and the uppercase letters A through Z representing values 36 through 61. For example, Aa represents .
The problem takes two strings that represent two distinct base 62 integers and asks which integer is smaller. Nick assumed that the string that comes first in lexicographic order is always the smaller integer, and he wrote his judge solution with that assumption.
For each test case, determine whether Nick's solution reports the correct result.
Input
The first line contains a single integer (), the number of test cases.
Each test case consists of two lines. The first line contains an alphanumeric string of length at most . The second line contains an alphanumeric string of length at most .
Both strings have no unnecessary leading zeroes, and the two strings in a test case are distinct. The sum of the lengths of all input strings across all test cases is at most .
Output
For each test case, print YES if the lexicographically smaller string represents the smaller integer in base 62. Otherwise, print NO.