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

Using DeepDiff for Object Comparison in Python

DeepDiff is a Python library designed to compare objects and identify differences between them. It supports various data types including dictionaries, iterables, strings, and more. Installation Install the library using pip: pip install deepdiff==4.3.2 Comparing Text Files To compare text files, read their contents and pass them to DeepDiff: f ...

Posted on Sun, 17 May 2026 20:57:01 +0000 by buddysal

Automating Duplicate File Management with Python

Automating Duplicate File Management with Python When managing large collections of files, duplicates can accumulate and consume unnecessary storage space. This solution demonstrates how to use Python to automatically identify and relocate duplicate files to a designated directory. Implementation Approach The following Python script implemen ...

Posted on Sat, 16 May 2026 15:03:58 +0000 by lily

How ConcurrentHashMap Reduces Contention with Thread Probes

ConcurrentHashMap utilizes a mechanism known as a thread probe to minimize contention among threads. When a thread adds an element to the map, it uses not only the key's hash but also a dedicated thread-specific probe value to select a bucket. This strategy helps distribute work across different buckets, reducing the likelihood of collisions. U ...

Posted on Wed, 13 May 2026 16:15:24 +0000 by yapyapayap