Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given N fractions. Fractions are represented as two arrays, X and Y of length N, containing the fraction numerators and denominators respectively. Write

image text in transcribed

You are given N fractions. Fractions are represented as two arrays, X and Y of length N, containing the fraction numerators and denominators respectively. Write a function solution that, given such arrays X and Y of length N, returns the number of possible ways to choose a pair of fractions that sum up ti. Since the answer can be large, provide it modulo 109+7(1,000,000,007). Note that a single fraction can form multiple pairs. Examples: 1. Given X=[1,1,2],Y=[3,2,3], the function should return 1 . The input represents fractions 1/3,1/2,2/3, and the only pair that sums up to 1 is (1/3,2/3). 2. Given X=[1,1,1],Y=[2,2,2], the function should return 3 . The input represents 1/2,1/2,1/2. There are three ways to choose a pair that sums up to 1 . 3. Given X=[1,2,3,1,2,12,8,4],Y=[5,10,15,2,4,15,10,5]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago