Backtracking Algorithms for Combination and Palindrome Partitioning

Problem 1: Combination Sum Given an array of distinct integers candidates and a target integer target, find all unique combinations where the chosen numbers sum to target. Each number may be used unlimited times. Algorithm Approach: The solution uses backtracking with a key condition: when exploring further elements, we start from the current i ...

Posted on Mon, 26 Oct 2026 16:50:21 +0000 by shortkid422

Implementing Union-Find and KMP Algorithm in Java

Union-Find (Disjoint Set Union) The Union-Find data structure supports two primary operations in near O(1) time: checking whether two elements belong to the same set, and merging two disjoint sets into one. It maintains three internal mappings: elementMap: maps user-provided values to internal Element wrappers fatherMap: maps each element to i ...

Posted on Mon, 26 Oct 2026 16:44:24 +0000 by doddsey_65

LeetCode Weekly Contest 392 Solutions

Problem Set Overview Longest Strictly Increasing or Decreasing Subarray Lexicographically Smallest String with Distance Constraint Minimum Operations to Make Median Equal to K Minimum Cost Path in Weighted Graph Longest Strictly Monotonic Subarray The solution involves simulating the problem requirements. Two approaches are pr ...

Posted on Sun, 25 Oct 2026 16:33:14 +0000 by Diego17

Two Sum Problem in C#: Finding Indexes of Target Sum

Problem Statement Given an integer array nums and an integer target, find the indices of the two numbers such that they add up to the target. Each input will have exactly one solution, and the same element cannot be used twice. Return the answer as a tuple or array of indices. ### Examples Input: nums = [2,7,11,15], target = 9 Output: [0,1] I ...

Posted on Sun, 25 Oct 2026 16:16:27 +0000 by Heavy

Educational Codeforces Round 162 (Rated for Div. 2) - Virtual Participation Notes

Preface This virtual contest didn't go as smoothly as expected. I spent longer than anticipated on problem B. For problem D, I identified the solution approach quickly but failed to account for several edge cases, resulting in three wrong submissions. Moving forward, I need to pay closer attention to edge cases during competition and work throu ...

Posted on Sat, 24 Oct 2026 16:19:20 +0000 by trystan

Introduction to Segment Trees

What Is a Segment Tree? Tree Structure Overview A segment tree is a binary search tree where each node represents an interval or segment. It allows efficient querying and updating of range-based operations. Problem Scope Segment trees excel at handling dynamic range queries and updates, such as finding maximum, minimum, or sum values over inte ...

Posted on Sat, 24 Oct 2026 16:17:52 +0000 by Draicone

Solving a Competitive Programming Contest: Problem Analyses and Solutions

Problem T1: Geometry and Distances The first problem involves calculating two distances. The first is the distance from a given point to a line segment, and the second is the distance from the same point to a circle. The distance to the circle is straightforward: it's the distance from the point to the circle's center minus the radius. For the ...

Posted on Sat, 24 Oct 2026 16:14:38 +0000 by sv4rog

Solutions for AtCoder Beginner Contest 369 Problems

The sample cases cover all possible scenarios for this problem. int main() { int x, y; cin >> x >> y; int result = 0; if(x > y) swap(x, y); if(x == y) result = 1; else if((y - x) % 2) result = 2; else result = 3; cout << result << endl; return 0; } </details>### Problem B - Piano Keys Track positions for le ...

Posted on Wed, 21 Oct 2026 16:54:36 +0000 by peyups

Finding the Start of a Cycle in a Linked List

Given the head node of a linked list, return the node where a cycle begins. If no cycle exists, return null. The linked list cannot be modified. A cycle is present if a node can be reached again by continuously following the next pointer. The evaluation system internally uses an integer pos to denote the zero-based index where the tail connects ...

Posted on Wed, 21 Oct 2026 16:53:26 +0000 by DjMikeS

Identifying Well-Matched Competitors from Exam Scores

Given \(N\) students (\(N \le 1000\)), each student has a name (a string of at most 8 characters with no spaces) and three integer scores for Chinese, Mathematics, and English (each between 0 and 150). Two students are considered "well-matched competitors" if the absolute difference in each subject score is at most 5, and the absolute ...

Posted on Wed, 21 Oct 2026 16:36:42 +0000 by abselect