{"id":"9b5388cd-4f23-41c5-849c-cd51a9400370","name":"Find Anagram Mappings","description":"1. You are given two integer arrays(A and B), where B is an anagram of A.\r\n2. B is an anagram of A means B is made by randomizing the order of the elements in A.\r\n3. For every element in A, you have to print the index of that element in B.\r\n\r\nNote -> Both arrays(A and B) are of the same length.","inputFormat":"A number N\r\na1\r\na2.. N numbers\r\nb1\r\nb2.. N numbers","outputFormat":"N space separated integers.","constraints":"1 &lt;= length of both arrays &lt;= 10^4\r\n1 &lt;= A[i],B[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> findMapping(int a1[],int a2[],int n){\n //Write your code here\n}\n\nint main(){\n int n;\n cin >> n;\n int a1[n],a2[n];\n for(int i=0;i<n;i++){\n cin >> a1[i];\n }\n for(int i=0;i<n;i++){\n cin >> a2[i];\n }\n \n vector<int> ans = findMapping(a1,a2,n);\n for(auto a:ans){\n cout << a << \" \";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\tpublic static int[] anagramMappings(int[] arr1, int[] arr2) {\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner s = new Scanner(System.in);\r\n\t\tint n = s.nextInt();\r\n\t\tint[] a = new int[n];\r\n\t\tint[] b = new int[n];\r\n\t\tfor (int i = 0; i < a.length; i++) {\r\n\t\t\ta[i] = s.nextInt();\r\n\t\t}\r\n\t\tfor (int j = 0; j < b.length; j++) {\r\n\t\t\tb[j] = s.nextInt();\r\n\t\t}\r\n\t\tint[] res = anagramMappings(a, b);\r\n\t\tfor (int j = 0; j < res.length; j++) {\r\n\t\t\tSystem.out.print(res[j] + \" \");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n1 2 3 4 5 2\r\n4 3 2 1 5 2","sampleOutput":"3 2 1 0 4 5 ","questionVideo":"https://www.youtube.com/embed/jBkTf43X198?end=87","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"50bbc341-a3fb-4d7c-b4ba-d74873f1d33f","name":"Find Anagram Mappings","slug":"find-anagram-mappings","type":1}],"next":{"id":"3432da92-703e-46b0-a5d0-feed87b612cd","name":"Find Anagram Mappings MCQ","type":0,"slug":"find-anagram-mappings-mcq"},"prev":{"id":"b29e5b2b-208a-44c1-b909-5869780ccbf3","name":"K Anagrams","type":3,"slug":"k-anagrams"}}}

Find Anagram Mappings

1. You are given two integer arrays(A and B), where B is an anagram of A. 2. B is an anagram of A means B is made by randomizing the order of the elements in A. 3. For every element in A, you have to print the index of that element in B. Note -> Both arrays(A and B) are of the same length.

{"id":"9b5388cd-4f23-41c5-849c-cd51a9400370","name":"Find Anagram Mappings","description":"1. You are given two integer arrays(A and B), where B is an anagram of A.\r\n2. B is an anagram of A means B is made by randomizing the order of the elements in A.\r\n3. For every element in A, you have to print the index of that element in B.\r\n\r\nNote -> Both arrays(A and B) are of the same length.","inputFormat":"A number N\r\na1\r\na2.. N numbers\r\nb1\r\nb2.. N numbers","outputFormat":"N space separated integers.","constraints":"1 &lt;= length of both arrays &lt;= 10^4\r\n1 &lt;= A[i],B[i] &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> findMapping(int a1[],int a2[],int n){\n //Write your code here\n}\n\nint main(){\n int n;\n cin >> n;\n int a1[n],a2[n];\n for(int i=0;i<n;i++){\n cin >> a1[i];\n }\n for(int i=0;i<n;i++){\n cin >> a2[i];\n }\n \n vector<int> ans = findMapping(a1,a2,n);\n for(auto a:ans){\n cout << a << \" \";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\tpublic static int[] anagramMappings(int[] arr1, int[] arr2) {\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner s = new Scanner(System.in);\r\n\t\tint n = s.nextInt();\r\n\t\tint[] a = new int[n];\r\n\t\tint[] b = new int[n];\r\n\t\tfor (int i = 0; i < a.length; i++) {\r\n\t\t\ta[i] = s.nextInt();\r\n\t\t}\r\n\t\tfor (int j = 0; j < b.length; j++) {\r\n\t\t\tb[j] = s.nextInt();\r\n\t\t}\r\n\t\tint[] res = anagramMappings(a, b);\r\n\t\tfor (int j = 0; j < res.length; j++) {\r\n\t\t\tSystem.out.print(res[j] + \" \");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\n1 2 3 4 5 2\r\n4 3 2 1 5 2","sampleOutput":"3 2 1 0 4 5 ","questionVideo":"https://www.youtube.com/embed/jBkTf43X198?end=87","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"50bbc341-a3fb-4d7c-b4ba-d74873f1d33f","name":"Find Anagram Mappings","slug":"find-anagram-mappings","type":1}],"next":{"id":"3432da92-703e-46b0-a5d0-feed87b612cd","name":"Find Anagram Mappings MCQ","type":0,"slug":"find-anagram-mappings-mcq"},"prev":{"id":"b29e5b2b-208a-44c1-b909-5869780ccbf3","name":"K Anagrams","type":3,"slug":"k-anagrams"}}}
plane

Editor


Loading...

Find Anagram Mappings

easy

1. You are given two integer arrays(A and B), where B is an anagram of A. 2. B is an anagram of A means B is made by randomizing the order of the elements in A. 3. For every element in A, you have to print the index of that element in B. Note -> Both arrays(A and B) are of the same length.

Constraints

1 <= length of both arrays <= 10^4 1 <= A[i],B[i] <= 10^5

Format

Input

A number N a1 a2.. N numbers b1 b2.. N numbers

Output

N space separated integers.

Example

Sample Input

6 1 2 3 4 5 2 4 3 2 1 5 2

Sample Output

3 2 1 0 4 5

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode