← 返回 nvidia 的题目列表Modified Rolling Hash Algorithm
类型:online_judge
In a system, you need to find a variant of a string and ensure that each character of the variant has a corresponding character in the original string, and the order is consistent. For example, given the string "石漆", its variant can be "漆石", and both variants are valid. Implement a function to determine if two strings are variants of each other. Use the following interface to write the program:
def is_variant(s: str, t: str) -> bool:
pass
Input Description:
The input consists of two strings containing only Chinese characters and having the same length.
Output Description:
Return True if the two strings are variants of each other, otherwise return False.
Data Constraint:
The length of the strings does not exceed 1000.
Test Cases:
Input: "石漆", "漆石", Output: True
Input: "石漆", "石石", Output: False
Input: "凌鹰", "鹰凌", Output: True
Input: "天竺", "竺大", Output: False
Input: "攻城狮", "城攻狮", Output: True
Example
Input
"石漆", "漆石"