admin@onlinelearningcenter.in (+91) 7 999 01 02 03

GCDs of given index ranges in an array

Jaivik Shah
6 Posts

Given an array a[0 . . . n-1]. We should be able to efficiently find the GCD from index qs (query start) to qe (query end) where 0 <= qs <= qe <= n-1.

Example:

Input:

a[] = {2, 3, 60, 90, 50};
Index Ranges : {1, 3}, {2, 4}, {0, 2}

 

 Output:

GCDs of given ranges are 3, 10, 1

 

 

Published By : Jaivik Shah
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin