解题思路:
(1)使用unordered_map的键值对存储B的值和位置
(2)对A中的每个数提供查找
class Solution {
public:
/**
* @param A: lists A
* @param B: lists B
* @return: the index mapping
*/
vector<int> anagramMappings(vector<int> &A, vector<int> &B) {
// Write your code here
unordered_map<int,int> mp;
vector<int> res;
for(int i=0;i<B.size();i++) {
mp[B[i]]=i;
}
for(auto w:A) {
res.push_back(mp[w]);
}
return res;
}
};