Tag Archives: Segment-Tree

How to prepare for ACM – ICPC?

ACM ICPC(Association for Computing Machinery – International Collegiate Programming Contest) is a world-wide annual multi-tiered programming contest being organized for over thirteen years. The contest is sponsored by IBM. This article focuses on what all topics that are important for the competitive programming and should especially be studied in order to train yourself for upcoming… Read More »

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 »