Segment Tree Template for Competitive Programming: Point Updates and Range Queries

The following reusable segment tree implementation uses 0-based indexing with half-open intervals [l, r). It supports point assignment, point addition, range queries, and methods to locate the first or last endex satisfying a custom predicate. #include <bits/stdc++.h> template<typename Info> struct SegmentTree { int size = 0; ...

Posted on Thu, 07 May 2026 09:24:23 +0000 by ainoy31

Linear Basis Implementation for XOR Operations

Construction AlgorithmThe Linear Basis structure maintains a set of linearly independent vectors to solve problems involving the XOR operation. To insert a value into the basis, we process the bits from the most significant bit (MSB) to the least significant bit (LSB).Let basis[] be the array storing the basis elements, initialized to 0. For an ...

Posted on Thu, 07 May 2026 07:02:32 +0000 by afrancis

Understanding Arrays in Go Programming

Arrays in Go represent fixed-length sequences of elements with the same type. Each element in an array is accessible by its index, and the total number of elements defines the array's length. Array Declaration Syntax Go provides several ways to declare arrays: var byteArray [32]byte // 32-element byte array var pointArray [1000]*floa ...

Posted on Thu, 07 May 2026 05:03:49 +0000 by fluteflute

Working with Java's HashSet Collection

HashSet implements the Set interface in Java using a hash table as its underlying data structure. It maintains a collection of unique elements, preventing duplicate entries from being stored. Each element in a HashSet is associated with a unique key derived from its hashCode() method. This hash value serves as an index for storing and retrievin ...

Posted on Thu, 07 May 2026 03:24:05 +0000 by will35010