Prefix Sum (Pre Sum) in Competitive Programming

Let’s go deep into Prefix Sum (Pre Sum) from a competitive programming perspective.This is one of the fundamental techniques you’ll repeatedly use in array, string, DP, and number theory problems. What is Prefix Sum? For an array arr[0..n-1], the prefix sum array pre[i] is defined as: That is, the cumulative sum up to index i. … Read more

Mastering Greedy Algorithms

Greedy algorithms are one of the most elegant problem-solving strategies in computer science. They are fast, intuitive, and often surprisingly effective—but only when applied to the right problems. This guide walks you through the recipe for designing greedy algorithms, the common proof techniques, and the classic patterns you must know. What Is a Greedy Algorithm? … Read more

Math Tricks in Competitive Programming

Competitive programming is not just about knowing programming syntax—it’s a blend of logic, speed, and mathematics. Mastering a few essential math tricks can drastically boost your problem-solving skills and efficiency. Let’s explore the most powerful and commonly used math techniques in competitive programming. Prime Numbers A prime number is a number greater than 1 that … Read more

Complete Guide to Matrices

Matrices are fundamental data structures in computer science and mathematics. In competitive programming, matrices are widely used in problems involving 2D grids, dynamic programming, graph algorithms, geometry, and simulations. Basics of Matrices in Python Python doesn’t have a native matrix type. A matrix is typically represented as a list of lists: Concepts Matric Representation Initialisation … Read more

The Ultimate Beginner’s Guide for Competitive programming Part 1

Competitive programming or sport programming is a mind sport involving participants trying to program according to provided specifications. Recursion Recursion is one of the most powerful and elegant tools in programming or even in competitive — but it can seem confusing at first. In this guide, you’ll learn what recursion is, how to identify recursive … Read more

Coding Level 1

Modulo % Example to show Modulus operator: Refer Extract Last Digit(s) of a Number Digit separation Reverse a number Decimal to binary Using Bitwise Refer Binary to Decimal Using bitwise Array Reverse an Array Array Rotation Method 1 : Using Mod (%) Consider it as circular array and use the property of mod and requires … Read more