SalesforceOA #42
Tool Changer
估计简单可在线判题
考点(AI 标注)原地数组模拟/实现
Tool names are arranged in circular order, and duplicates are allowed. You start at startIndex, and each move goes one position left or right; find the minimum number of steps to reach any position holding the target name. Added by this site: output −1 if the target cannot be found. Names match only if they are exactly equal; case and whitespace must not be ignored.
输入格式
The input is a JSON array [tools,startIndex,target], with zero-based indices. The original has no numeric or character bounds; this site adds 1≤n≤100000, each name and target has length 0..16 Unicode scalar values, and empty names, whitespace, NUL, and non-BMP characters are allowed, but lone surrogates are not; 0≤startIndex<n. The entire JSON-encoded input is ≤20000000 bytes, so ASCII-escaped encoding can cover the complete worst-case name domain.
输出格式
Output one integer answer.
样例 1
输入:
[["ballendmill","keywaycutter","slotdrill","facemill"],1,"ballendmill"]
输出:
1
样例 2
输入:
[["","a",""],1,""]
输出:
1
样例 3
输入:
[["\ud83d\ude00","\u0000"],0,"absent"]
输出:
-1
样例说明
The outputs of the three public examples are, in order: 1; 1; -1. They have been checked by independent enumeration or direct simulation.