Understanding the Execution Order of Logic in Binary Tree Recursion
The placement of code within a recursive function significantly impacts how the program interatcs with the state of a binary tree. This is particularly evident when using external or persistent variables to track the relationship between different nodes during traversal.
Impact of Early Assignment
When calculating the minimum absolute differenc ...
Posted on Sun, 07 Jun 2026 18:17:22 +0000 by djsl
GESP Practice Problems: Reading, Scheduling, Geometry, and Bit Patterns
Holiday Reading
A book has n pages. A student can read at most k pages per day over t vacation days. The maximum number of pages they can finish is the smaller of n and k * t.
n = int(input())
k = int(input())
t = int(input())
print(min(n, k * t))
Shared Duty Schedule
Two students clean on cycles of m and n days. The next time they coincide i ...
Posted on Sun, 07 Jun 2026 17:44:57 +0000 by cmanhatton
Algorithmic Solutions for String Processing, Greedy Maximization, and Graph Dependencies
Prefix Matching and Keyboard Layout Reconstruction
This problem involves identifying possible next characters based on a given prefix and mapping them to a specific $4 \times 8$ grid layout. The core task is to filter a list of strings that start with a specific sequence and mark the character that immediately follows that sequence.
#include &l ...
Posted on Sun, 07 Jun 2026 16:46:38 +0000 by rednax
Understanding and Implementing Stacks for Algorithmic Problem Solving
Stack Fundamentals
A stack is a linear data structure that adheres to the Last-In, First-Out (LIFO) principle. This means the last element added to the stack is the first one to be removed. Operations on a stack are restricted to a single end, known as the top. The other end is called the bottom.
Think of a stack like a stack of plates. You ...
Posted on Sat, 06 Jun 2026 17:34:57 +0000 by Tobeon
Binary Search Tree: Insertion, Deletion, and Traversal
Binary Search Tree
A Binary Search Tree (BST) is a node-based binary tree data structure which has the following propetries:
The left subtree of a node contains only nodes with keys lesser than the node's key.
The right subtree of a node contains only nodes with keys greater than the node's key.
The left and right subtree each must also be a b ...
Posted on Fri, 05 Jun 2026 17:59:32 +0000 by djpeterlewis
Comprehensive Guide to Dynamic Programming Patterns and Implementations
Minimum Path Sum in a Grid
Finding the minimum path sum from the top-left to the bottom-right of a grid is a classic dynamic programming problem. To optimize space complexity, we can use a 1D array instead of a 2D matrix to store the DP states, updating the array iteratively as we traverse each row.
#include <vector>
#include <algorith ...
Posted on Thu, 04 Jun 2026 17:28:26 +0000 by m4tt
Binary Search and Memoized DFS for Optimization Problems
Maximizing Minimum Distance Between ElementsGiven an array of unique positions and a number of items to place, the goal is to position the items such that the minimum absolute difference between any two items' positions is maximized.Example 1:Input: positions = [1,2,3,4,7], items = 3Output: 3Explanation: Placing items at positions 1, 4, and 7 y ...
Posted on Thu, 04 Jun 2026 16:01:15 +0000 by cash09
Java Programming Exercises: Basic Logic and Algorithms
1. Create a program that maps input numbers 1-7 to corresponding days of the week.package com.examples.core;<br><br>import java.util.Scanner;<br><br>public class DayMapper {<br> public static void main(String[] args) {<br> Scanner scanner = new Scanner(System.in);<br> System.out.println ...
Posted on Wed, 03 Jun 2026 16:40:27 +0000 by kettle_drum
Contest Problem Solutions: Factorization, Rays, String Construction, and Tree Partitioning
Factorization into Factorial Divisors
Given integers (n) and (m) where (1 \le m \le n!) and (n \le 20), decompose (m) into a sum of at most (n) divisors of (n!). A solution is guaranteed to exist.
Define a sequence (d_i = \frac{n!}{i!}) for (i) from 1 to (n). By iterating downwards from (i=n) to (1) and greedily subtracting the largest possible ...
Posted on Mon, 01 Jun 2026 17:41:27 +0000 by taldos
Inside Python’s Set Implementation: Mechanics and Operations
Core Mechanics and Hashing
Python's set type delivers an unordered collection of distinct objects. Its underlying architecture relies on a hash table, which enables near-constant time complexity for insertion, lookup, and deletion operations.
Hash Table Fundamentals
A hash table maps keys to array indices using a deterministic hashing algorithm ...
Posted on Mon, 01 Jun 2026 17:25:17 +0000 by Bopo