Solutions to AGC016 Programming Contest Problems
A - Shrinking
Given a string s, determine the minimum number of operasions required to make all characters identical. Each operation reduces the string length by one by selecting characters from adjacent positions.
#include <bits/stdc++.h>
using namespace std;
int main() {
string input;
cin >> input;
int length = input. ...
Posted on Fri, 19 Jun 2026 17:54:39 +0000 by decodv
Understanding the FIFO Queue Data Structure
Definition and Core Principles
A Queue is a fundamental linear data structure that operates on the First-In-First-Out (FIFO) principle. Conceptually, it functions similarly to a real-world waiting line: entities enter from one end, known as the rear, and exit from the opposite end, known as the front. This strict ordering ensures that the eleme ...
Posted on Fri, 19 Jun 2026 16:41:24 +0000 by disconne
FHQ Treap: A Non-Rotating Balanced Binary Tree Implementation
Data Structure DefinitionThe FHQ Treap (Fredman, Hendler, and Zhou Treap) relies on a randomized heap priority to maintain balance without requiring complex tree rotations. Each node in the structure maintains essential metadata: pointers to left and right children, the node's value, a random priority weight, and the size of the subtree rooted ...
Posted on Wed, 17 Jun 2026 17:45:38 +0000 by Backara_Drift
Solving the Two Sum Problem with Python
The objective is to identify two numbers within an integer array that sum up to a specific target value and return their indices. It is assumed that there is exactly one valid solution per input and that an element cannot be used twice.
For example, given the array nums = [2, 7, 11, 15] and target = 9, the function should return [0, 1] becuase ...
Posted on Tue, 16 Jun 2026 17:01:38 +0000 by ciaranmg
Constructing and Utilizing Biconnected Components Graphs
This document explores the concept of biconnected components (BCCs) and their representation using a specialized graph structure called a biconnected components graph, often referred to as a "circle-square tree" or "block-cut tree."
Construction
Similar to vertex-connectivity decomposition (v-dcc), the biconnected components ...
Posted on Tue, 16 Jun 2026 16:52:47 +0000 by zymosan
Algorithmic Review and Competition Strategies for NOIP
Contest preparation requires a structured approach to covering fundamental algorithms and optimizing problem-solving strategies. The following outlines core technical topics and execution practices essential for competitive programming.
Core Algorithms and Data Structures
Simulation and Mathematics
High-precision arithmetic is critical for p ...
Posted on Mon, 15 Jun 2026 17:54:23 +0000 by press711
Core Algorithmic Techniques in Java for Competitive Programming
Sorting, searching, dynamic programing, and graph algorithms form the backbone of competitive programming. This article presents a curated list of such patterns, each accompanied by a concise Java implementation. The examples draw inspiration from the ACwing problem set, covering topics from basic sorting to advanced combinatorial mathematics.
...
Posted on Mon, 15 Jun 2026 17:07:00 +0000 by zhaohongli
Implementing a Singly Linked List in C
Prerequisites
Before diving into the implementation, let's include the necessary header files:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int ELEMENT; // Custom data type alias
Structure Definitions
For a linked list implementation, we need to define a node structure and a list structure:
// Node str ...
Posted on Mon, 15 Jun 2026 16:14:12 +0000 by fly_hyp
How LinkedHashMap Maintains Order with a Hash Table and Doubly Linked List
LinkedHashMap extends HashMap to preserve the order of entries—either by insertion or access sequence—while retaining O(1) average-time complexity for lookups. It achieves this by combining HashMap’s hash table structure with an additional doubly linked list that tracks entry order.
Core Structure
LinkedHashMap reuses HashMap’s underlying array ...
Posted on Sun, 14 Jun 2026 18:15:50 +0000 by ComputerChip
LeetCode 54: Spiral Matrix and 445: Add Two Numbers II
LeetCode 54: Spiral Matrix
Problem
Given an m x n matrix, return all elements of the matrix in spiral order.
Example 1
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,3,6,9,8,7,4,5]
Example 2
Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Output: [1,2,3,4,8,12,11,10,9,5,6,7]
Approach
Traverse from left to right along the top r ...
Posted on Sun, 14 Jun 2026 16:12:36 +0000 by thebusinesslad