`{"id":"f2e56e1d-738e-4ebd-84c9-73e2e9268ee5","name":"Difference Of Two Arrays","description":"1. You are given a number n1, representing the size of array a1.\r\n2. You are given n1 numbers, representing elements of array a1.\r\n3. You are given a number n2, representing the size of array a2.\r\n4. You are given n2 numbers, representing elements of array a2.\r\n5. The two arrays represent digits of two numbers.\r\n6. You are required to find the difference of two numbers represented by two arrays and print the arrays. a2 - a1\r\n\r\nAssumption - number represented by a2 is greater.","inputFormat":"A number n1\r\nn1 number of elements line separated\r\nA number n2\r\nn2 number of elements line separated","outputFormat":"A number representing difference of two numbers (a2 - a1), represented by two arrays.","constraints":"1 &lt;= n1, n2 &lt;= 100\r\n0 &lt;= a1[i], a2[i] &lt; 10\r\nnumber reresented by a1 is smaller than number represented by a2","sampleCode":{"cpp":{"code":"#include<iostream>\r\n#include<vector>\r\nusing namespace std;\r\n\r\nint main(){\r\n int n1, n2;\r\n \r\n cin>>n1;\r\n vector<int> a1(n1, 0);\r\n for(int i = 0 ; i < n1; i++){\r\n cin>>a1[i];\r\n }\r\n \r\n cin>>n2;\r\n vector<int> a2(n2, 0);\r\n for(int i = 0 ; i < n2; i++){\r\n cin>>a2[i];\r\n }\r\n \r\n //write your code here\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"n1 = int(input())\r\narr1 = []\r\nfor i in range(n1):\r\n val = int(input())\r\n arr1.append(val)\r\n \r\nn2 = int(input())\r\narr2 = []\r\nfor i in range(n2):\r\n val = int(input())\r\n arr2.append(val)\r\n \r\n# write your code here"}},"points":10,"difficulty":"easy","sampleInput":"3\r\n2\r\n6\r\n7\r\n4\r\n1\r\n0\r\n0\r\n0","sampleOutput":"7\r\n3\r\n3","questionVideo":"https://www.youtube.com/embed/LQom9iFG1F0","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":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"b3f4db87-16c4-4f8f-be17-d0a01f88f905","name":"Difference Of Two Arrays","slug":"difference-of-two-arrays","type":1}],"next":{"id":"6e7882be-7546-4ccc-9c05-9a6e285e127f","name":"Difference Of Two Arrays","type":3,"slug":"difference-of-two-arrays"},"prev":{"id":"0580ba15-ec6b-4284-8a7f-e1bdffbc9e43","name":"Sum Of Two Arrays","type":3,"slug":"sum-of-two-arrays"}}}`

# Difference Of Two Arrays

1. You are given a number n1, representing the size of array a1. 2. You are given n1 numbers, representing elements of array a1. 3. You are given a number n2, representing the size of array a2. 4. You are given n2 numbers, representing elements of array a2. 5. The two arrays represent digits of two numbers. 6. You are required to find the difference of two numbers represented by two arrays and print the arrays. a2 - a1 Assumption - number represented by a2 is greater.

`{"id":"f2e56e1d-738e-4ebd-84c9-73e2e9268ee5","name":"Difference Of Two Arrays","description":"1. You are given a number n1, representing the size of array a1.\r\n2. You are given n1 numbers, representing elements of array a1.\r\n3. You are given a number n2, representing the size of array a2.\r\n4. You are given n2 numbers, representing elements of array a2.\r\n5. The two arrays represent digits of two numbers.\r\n6. You are required to find the difference of two numbers represented by two arrays and print the arrays. a2 - a1\r\n\r\nAssumption - number represented by a2 is greater.","inputFormat":"A number n1\r\nn1 number of elements line separated\r\nA number n2\r\nn2 number of elements line separated","outputFormat":"A number representing difference of two numbers (a2 - a1), represented by two arrays.","constraints":"1 &lt;= n1, n2 &lt;= 100\r\n0 &lt;= a1[i], a2[i] &lt; 10\r\nnumber reresented by a1 is smaller than number represented by a2","sampleCode":{"cpp":{"code":"#include<iostream>\r\n#include<vector>\r\nusing namespace std;\r\n\r\nint main(){\r\n int n1, n2;\r\n \r\n cin>>n1;\r\n vector<int> a1(n1, 0);\r\n for(int i = 0 ; i < n1; i++){\r\n cin>>a1[i];\r\n }\r\n \r\n cin>>n2;\r\n vector<int> a2(n2, 0);\r\n for(int i = 0 ; i < n2; i++){\r\n cin>>a2[i];\r\n }\r\n \r\n //write your code here\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"n1 = int(input())\r\narr1 = []\r\nfor i in range(n1):\r\n val = int(input())\r\n arr1.append(val)\r\n \r\nn2 = int(input())\r\narr2 = []\r\nfor i in range(n2):\r\n val = int(input())\r\n arr2.append(val)\r\n \r\n# write your code here"}},"points":10,"difficulty":"easy","sampleInput":"3\r\n2\r\n6\r\n7\r\n4\r\n1\r\n0\r\n0\r\n0","sampleOutput":"7\r\n3\r\n3","questionVideo":"https://www.youtube.com/embed/LQom9iFG1F0","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":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"b3f4db87-16c4-4f8f-be17-d0a01f88f905","name":"Difference Of Two Arrays","slug":"difference-of-two-arrays","type":1}],"next":{"id":"6e7882be-7546-4ccc-9c05-9a6e285e127f","name":"Difference Of Two Arrays","type":3,"slug":"difference-of-two-arrays"},"prev":{"id":"0580ba15-ec6b-4284-8a7f-e1bdffbc9e43","name":"Sum Of Two Arrays","type":3,"slug":"sum-of-two-arrays"}}}`

Editor

# Difference Of Two Arrays

easy

1. You are given a number n1, representing the size of array a1. 2. You are given n1 numbers, representing elements of array a1. 3. You are given a number n2, representing the size of array a2. 4. You are given n2 numbers, representing elements of array a2. 5. The two arrays represent digits of two numbers. 6. You are required to find the difference of two numbers represented by two arrays and print the arrays. a2 - a1 Assumption - number represented by a2 is greater.

## Constraints

1 <= n1, n2 <= 100 0 <= a1[i], a2[i] < 10 number reresented by a1 is smaller than number represented by a2

## Format

### Input

A number n1 n1 number of elements line separated A number n2 n2 number of elements line separated

### Output

A number representing difference of two numbers (a2 - a1), represented by two arrays.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}3 2 6 7 4 1 0 0 0```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}7 3 3```

Question Video

Discussions

Show Discussion

Related Resources