Online assessment
Anonymous User
404

Can anyone help me with this question
The Problem is :
You are given two sets of numbers A and B. You should find a subset A’ of A and another subset B’ of B such that :
1.A’ and B’ are non-empty

  1. For each element in A’ and each element in B’, a*b is a perfect cube.
    3.|A’|^2 + |B’|^2 is maximised

Example Input:
A=2,16,5
B=4,4

Output:
8
explanation :- {2,16},{4,4} for every element of ij it is a perfect cube so 2**2+2**2 =8
Constraints :-
Length of A and B are 5*(10**5)
As Constraints are too high we should do a optimised approach
I iterated through the all the possible cubes by finding maximum cube and checking if the cube is possible by checking in either list using set.After that i tried maximum possible intersection.

Comments (1)