Consecutive subset product -


i got interview question , thinking on how solve it. lets number array ={7,6,3} , consequtive substring ares {7},{6},{3},{7,6},{6,3},{7,6,3}({7,3} not valid) check if product of 2 subsets equal).

so {6,2,3} fails {6}={2*3} can give me nudge in right direction.

if there n numbers in array. there n * (n - 1) / 2 consequtive subsets. can pre-process thess subsets' product, , insert map. enum subsets find if product have more twice in map. can solve question.


Comments