Binary Lifting and Lowest Common Ancestor
Introduction
Given an integer array of size n.
There are m queries, each query consists of two integers x and y, asking for the maximum value in the range [x, y] of the array.
Approach
A straightforward method would be to precompute f[i][j] representing the maximum value from index i to j. However, this approach is inefficient.
Instead, we can ...
Posted on Fri, 03 Jul 2026 16:49:36 +0000 by Gighalen
Essential Techniques for Competitive Programming: Bit Manipulation, Discretization, and DP Fundamentals
Core Problem-Solving Strategies
Bitwise Operations
Bitwise operators provide efficient alternatives to arithmetic operations:
Operator
Description
Behavior
&
AND
Result is 1 only if both bits are 1
|
OR
Result is 0 only if both bits are 0
^
XOR
Result is 1 when bits differ
~
NOT
Flips all bits
<<
Left Shift
Shifts bits ...
Posted on Wed, 20 May 2026 20:06:51 +0000 by Nuser
Finding the Leftmost Meeting Point in a Sequence of Buildings
This problem asks us to identify the earliest possible building index where two individuals, starting from distinct locations, can rendezvous. We are provided with an array representing building heights, let's call it buildingElevations, and a series of queries. Each query specifies two initial building indices, startA and startB.
The rule for ...
Posted on Mon, 11 May 2026 11:46:07 +0000 by Tryfan