Marks :100
: 1 | : 0
Array operations are boring and fun.
You are given an array of integers ($$$a_i,a_{i+1}..........a_{n-1}$$$) and ($$$b_i,b_{i+1}.......b_{n-1}$$$).Lets define a transformation of array a: Choose any non negative integer k such that ($$$0 \le k \le n $$$),Choose k distinct indices ($$$1 < i_1 < i2 .....< i_k \le n$$$). Add 1 to each ($$$a_{i1},a_{i2}....a_{ik}$$$) all other elements of array a remains unchanged . Permute elements of the array a in any order.
Is it possible to perform some transformation of the array exactly once, So the resulting array is equal to b?
If it is possible then print YES else print NO
The first line of the test case contains an integer N ($$$1 \le n \le 1e5 $$$)the length of arrays A and B.
The next line contains n spaced integers of array A that is ($$$a_i,a_{i+1}.......a_{n-1}$$$).
The next line contains n spaced integers of array B that is ($$$b_i,b_{i+1}......b{n-1}$$$).
For each test case print Yes or No if it is possible to make array A equal to array B or not.
5 1 2 3 4 5 5 1 1 3 4
NO
3 1 2 3 2 3 4
YES
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.