Algorithmic Solutions for Programming Contest Problems
Given an integer, determine if it is a palindrome.
The straightforward apprroach is to treat the input as a string and check if it reads the same forwards and backwards, which can be done in O(n) time where n is the length of the string.
A more efficient approach uses polynomial hashing with O(n) time complexity. We'll implement both forward an ...
Posted on Sun, 02 Aug 2026 16:19:16 +0000 by briglia23
Counting Identification Cards That Clear All Gates Using Interval Intersection
We have N identification cards, numbered from 1 to N, and M gates. The i-th gate can be passed by any card whose number lies in the inclusive range [L_i, R_i]. Find the number of cards that can pass through all M gates individually.
Input is given on standard input in the following format:
N M
L1 R1
L2 R2
...
LM RM
Print a single integer: the ...
Posted on Sun, 12 Jul 2026 17:26:46 +0000 by coldkill