Company: Edgeverve_17_jan
Difficulty: medium
Reorder it 2. Reorder it Problem Description You are given two integer arrays, A and B , both of length N , and an integer P which will be used for hashing. An array C of length N is formed as follows: C[i] = (A[i] + B[i]) % N . You are allowed to reorder the elements of one of the arrays, either A or B , but not both . Your goal is to perform this reordering in such a way that the resulting array C is lexicographically smallest . Your task is to find the lexicographically smallest possible array C and then return its hash value. Note: Let C be 0-indexed. The hash is defined as: hash = ( ∑ (C[i] * P i ) ) % (10 9 + 7) for i from 0 to N-1 . Function Description Complete the Solve function in the editor below. It has the following parameter(s): N : An INTEGER, the size of the arrays A and B. P : An INTEGER, the base for hashing. A : An INTEGER ARRAY, the array A. B : An INTEGER ARRAY, the array B. Return The function must return an INTEGER denoting the hash value of the lexicographic