AtCoder Beginner Contest 049 Solutions

Problem A Determine if a given character is one of the vowels a, e, i, o, u. A simple approach uses a hash map to store the vowels. For efficiency, characters are hashed by subtracting 'a', and a custom hash table implementation handles lookups. template <class T, int P = 314159> struct hashmap { u64 id[P]; T val[P]; int rec[P ...

Posted on Mon, 24 Aug 2026 16:13:46 +0000 by noobh

Solving Longest Valid Parentheses, Trapping Rain Water, and Wildcard Matching Problems

Longest Valid Parentheses Given a string containing only '(' and ')', find the length of the longest valid (well-formed and contiguous) parentheses substring. Dynamic Programming Solution Define dp[i] as the length of the longest valid parentheses ending at position i. To each character at index i: If s[i] is '(', set dp[i] = 0 If s[i] is ')', ...

Posted on Sat, 16 May 2026 08:12:44 +0000 by mitchell_1078

Fixed-Size Sliding Window Technique for Identifying String Anagrams

Problem Definition Given two strings s and p, identify every starting index within s where a substring contains the exact same characters as p with identical frequencies. Character order is irrelevant for matching purposes. Example: With s = "cbaebabacd" and p = "abc", the qualifying substrings apppear at indices 0 ("cb ...

Posted on Thu, 14 May 2026 07:21:00 +0000 by onyx