Hash-Based Algorithms for String and Array Problems
1. Valid Anagram
Given two strings s and t, determine if they are anagrams — i.e., contain the exact same characters with the same frequencies.
Since characters are constrained to lowercase English letters, a fixed-size integer array of length 26 suffices for counting frequencies.
public boolean checkAnagram(String text1, String text2) {
i ...
Posted on Fri, 12 Jun 2026 16:26:39 +0000 by FillePille
LeetCode Problem Solutions: Sliding Window and Hash Table Techniques
Trpaping Rain Water Problem
Given an array representing elevation maps, this problem calculates how much water can be trapped between bars after raining.
vector<int> leftMax(n, 0);
vector<int> rightMax(n, 0);
if (n == 0) return 0;
leftMax[0] = height[0];
rightMax[n-1] = height[n-1];
for (int i = 1; i < n; ++i) {
leftMax[i] = ...
Posted on Fri, 15 May 2026 23:00:45 +0000 by jck
Hash Table Applications in LeetCode Top Interview Questions
Hash table are primarily used to store key-value mappings, enabling efficient lookups. They exemplify a time-space tradeoff—using extra memory to reduce time complexity for search operations.
Two Sum
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Because nums[0] + nums[1] == 9.
A naive approach uses nested loops, resulting in O(n²) time co ...
Posted on Wed, 13 May 2026 11:27:49 +0000 by vipul73
Finding the Intersection Node of Two Linked Lists
Given the head nodes headA and headB of two singly linked lists, determine the node at which the two lists intersect. Return the intersecting node. If no intersection exists, return null.
The linked list structure is guraanteed to be acyclic. The original structure of both lists must remain unchanged after the function returns.
Example 1:
Input ...
Posted on Thu, 07 May 2026 16:21:41 +0000 by eMonk