Stack-Based Solutions for Valid Parentheses, Duplicate Removal, and Reverse Polish Notation
Valid Parentheses
The solution utilizes a stack data structure to validate parentheses. When encountering an opening bracket, it is pushed onto the stack. For closing brackets, the algorithm checks whether the top of the stack matches the corresponding opening bracket. If not, the input is invalid. After processing all characters, a valid expre ...
Posted on Fri, 12 Jun 2026 18:08:11 +0000 by sandrob57
Contest Round 33 Editorial: Emphasis on Algorithmic Thinking
A. Word Rearrangement
This is a straightforward problem requiring only basic input/output handling.
w1, w2 = input().split()
print(w2)
print(w1)
B. Cooking Tangyuan
The key idea is to simulate the process of using packages to fulfill cooking rounds. Each package contributes a fixed number of tangyuan, and excess can carry over.
n, x, k = map(i ...
Posted on Sun, 17 May 2026 14:48:21 +0000 by Fjerpje
Finding the Longest Palindromic Substring in Linear Time Using Manacher's Algorithm
Problem Statement
Given a string of length (n), find the length of the longest palindromic substring where (n \le 10^5).
Brute-Force Approach
A straightforward method involves iterating through each position as a potential center and expanding outward in both directions to check for palindromes. Taking the maximum length among all centers yield ...
Posted on Thu, 07 May 2026 03:39:19 +0000 by mdomel