Redis Internal Storage Architecture and Data Structures
Redis Storage Structure
Value Encoding Types
Redis automatically selects the most efficient encoding format based on the characteristics of stored data:
String
int: String length ≤ 20 and convertible to integer
raw: String length > 44
embstr: String length ≤ 44
List
quicklist: Optimized linked list structure
ziplist: Compressed list for ...
Posted on Thu, 16 Jul 2026 16:59:55 +0000 by jeff2007XP
Understanding Cardinality Estimation Algorithms
For example, consider an array a[10] = {1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7}. The task is to count the number of distinct elements, which in this case would be {1, 2, 3, 4, 5, 6, 7}, totaling seven unique values. Similarly, in web analytics, you may want to track individual users like "Xiaoming" with out repeatedly counting their visits, ...
Posted on Mon, 06 Jul 2026 16:59:54 +0000 by AchillesForce
Find the Longest Consecutive Sequence in O(n) Time
To find the longest sequence of consecutive integers in an unsorted array with O(n) time complexity, use the following approach:
Insert all elements into an unordered_set, which prvoides average O(1) lookup time and atuomatically removes duplicates.
Iterate through each number in the set. Only start counting a sequence if the current number is ...
Posted on Tue, 30 Jun 2026 16:54:59 +0000 by manamino
Hash Table Algorithms: Solving Multi-Sum Problems
Hash Table Algorithms: Solving Multi-Sum Problems
4Sum II (LeetCode 454)
Problem Description
Given four integer arrays nums1, nums2, nums3, and nums4, all of length n, return the number of tuples (i, j, k, l) such that:
0 <= i, j, k, l < n
nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0
Example 1:
Input: nums1 = [1,2], nums2 = [-2,-1 ...
Posted on Mon, 22 Jun 2026 16:42:09 +0000 by sanlove
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