Category Archives: Advanced Data Structure

Min-Max Range Queries

Given an array arr[0 . . . n-1]. We need to efficiently find the minimum and maximum value from index qs (query start) to qe (query end) where 0 <= qs <= qe <= n-1. We are given multiple queries. Examples: Input : arr[] = {1, 8, 5, 9, 6, 14, 2, 4, 3, 7}… Read More »

Range LCM Queries

Given an array of integers, evaluate queries of the form LCM(l, r). There might be many queries, hence evaluate the queries efficiently. LCM (l, r) denotes the LCM of array elements that lie between the index l and r (inclusive of both indices) Mathematically, LCM(l, r) = LCM(arr[l], arr[l+1] , ……… , arr[r-1], arr[r]) Examples:… Read More »