cswork / OA打开练习工作台

AmazonOA #359

Check Similar Passwords (Also for Fungile)

估计中等可在线判题

考点(AI 标注)双指针滑窗字符串

For each request, choose any positions in new and change each of them once to its cyclic successor letter, or choose none. Determine whether old can become a subsequence of the modified new; a position cannot be changed more than once. The successor of z is a.

输入格式

The input is a JSON two-dimensional array whose items are [new,old]. Original: 1..10 requests, a total length of all new and old strings≤200000, and old length≤new length in each item. Characters are lowercase letters, following the original cyclic a..z definition; there is no non-empty requirement on individual strings, so empty strings are allowed.

输出格式

Output YES or NO on its own line for each request.

样例 1

输入:

[["baacbab","abdbc"],["accdb","ach"],["baacba","abb"]]

输出:

YES
NO
YES

样例 2

输入:

[["aaccbbee","bdbf"],["aab","aee"]]

输出:

YES
NO

样例 3

输入:

[["z","a"],["",""]]

输出:

YES
YES

样例说明

The public outputs are YES/NO/YES, YES/NO and YES/YES. The second paragraph of the original statement reverses the direction of the subsequence; this site restores the direction that agrees with the first paragraph, with old length≤new length, and with all examples.