Company: Media Net .
Difficulty: medium
Double Box Outlay II Problem Description Jack went to a game store intending to buy playing cards. In the store, he found N boxes, each containing a unique set of M numbered cards. Since he had many friends to play card games with, he wanted to purchase two boxes at the lowest possible cost, making sure that there were no duplicate numbered cards between the two chosen boxes. As Jack continues to explore the store's offerings, could you assist him in determining the minimum cost he must incur to buy these two non-overlapping sets of cards? You are given 2D array A of size N cross M, where A[i][j] represents the j-th numbered card of i-th box. You are also given an array B of size N, where B[i] represents the cost of i-th box. Find the minimum cost he must incur to buy these two non-overlapping sets of cards. If no such pair of boxes exists, return -1. Note: There can be two or more boxes with the same price, the same cards, or both. Constraints 2 <= N <= 10^4 1 <= M <= 4 1