You are given 2 int arrays.
A=[1, 2, 1]
B=[2, 3, 3]
so fractions are: 1/2, 2/3, 1/3
A is numerator, B is denominator. so fractions are: 1/2, 2/3, 1/3
Find all pairs that sum upto 1.
Example: here we have 2/3 + 1/3 = 1, so count = 1
return 1
return modulo 10^9 +7 since input can be large
I did it in O(n^2) by going through it once and then computing addition of the 2 and checking if its one and updating counter.
is possible in O(n)?
Any language idm example:
function solution(integer array A, integer array B){
return integer_counter;
}