Understanding HashMap Internals in JDK: Storage, Hashing, and Expansion
HashMap is one of the most widely used collections in Java applications, primarily for storing key-value pairs with efficient lookup performance. To understand its inner workings, we explore how it manages data storage, resolves collisions, handles resizing, and why it is not thread-safe.
Class Hierarchy and Core Interfaces
HashMap implements s ...
Posted on Mon, 28 Sep 2026 16:21:18 +0000 by mrhinman
Efficient Key-Value Storage Using Hash Tables
A hash table maps keys to values using a computed index, enabling fast lookup, insertion, and deletion. Understanding arrays and linked lists is essential before working with hash tables.
Core Mechanism
An array serves as the underlying storage, where each slot—called a bucket—holds a key-value pair. A hash function processes the key, and the r ...
Posted on Mon, 21 Sep 2026 16:29:03 +0000 by simon551
CSP-S 2022 Solutions
The problems in this set require careful handling of edge cases and efficient algorithms. Below are the solutions for all four tasks.
T1: Holiday Plan
Given constraints n ≤ 2.5 × 103, an O(n2) approach is feasible.
We enumerate the middle two vertices B and C. For a valid pair (B, C), we pre‑compute the set of possible A (from B) and possible D ...
Posted on Thu, 10 Sep 2026 16:44:49 +0000 by dscapuano
Dynamic Programming and Advanced Data Structures
A
The problem involves matrices and their properties. The key insight is to treat four types of brackets as distinct invertible matrices.
Two strings can be concatenated if their product equals the identity matrix. While this is a necessary condition, it's not sufficient. However, hashing can serve as an effective heuristic.
We maintain prefix ...
Posted on Sat, 05 Sep 2026 16:36:49 +0000 by ziola
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
Implementing Student-Course Mapping with C++ Vector Containers
Course Registration Query Using Vector ArraysWhen handling dynamic data where the number of items per entity varies, std::vector provides an ideal solution. Consider a scenario where we need to maintain course enrollment records and retrieve a specific student's course list on demand.Problem AnalysisThe input provides course information includi ...
Posted on Mon, 03 Aug 2026 16:44:23 +0000 by vaanil
String Hashing Techniques and Applications
Properties of String Hashing
Different hash values guarantee different strings.
Identical hash values don't guarantee identical strings (though probability is high).
Modulus Selection
Prime moduli are preferable based on number theory. For example, (ax + b) mod p distributes with interval gcd(a, p). The modulus must prevent overflow in 64-bi ...
Posted on Wed, 29 Jul 2026 16:20:42 +0000 by lalabored
Hashing: Group Statistics and String Subtraction
Problem B: Group Statistics
Given two lines of input: the first line contains numbers, and the second line contains their corresponding group IDs. Count the occurrences of each number in each group and output the statistics.
Problem Analysis
To solve this problem, you can:
Define two arrays numbers and groups to store the input numbers and the ...
Posted on Thu, 25 Jun 2026 16:59:50 +0000 by ReDucTor
Longest Common Substring Using Hashing
The problem involves finding the longest common substring between two strings composed solely of lowercase letters. The string lengths can reach up to 250,000.
The solution uses binary search combined with hashing techniques to efficiently determine the maximum length of the shared substring.
Let's denote the two input strings as $ s_1 $ and $ ...
Posted on Sat, 06 Jun 2026 17:48:41 +0000 by HuggyBear
Python Dictionary and Set Implementation Guide
Dictionary's Abstract Base Class Inheritance
In Python, dictionaries belong to the mapping type. Let's examine their inheritance relationship by examining the source code.
from collections.abc import Mapping, MutableMapping
Examining the MutableMapping source code:
class MutableMapping(Mapping):
__slots__ = ()
"""A MutableMapping ...
Posted on Sat, 23 May 2026 19:05:18 +0000 by rubenc