πΊοΈ Problem Map
A chronological journal of all 24 DSA problems solved in the AlgoChronicle.
Two Sum
O(n)
LeetCode
Pattern: Hash Table - Use hash map to store complements for O(n) lookup
Duplicate Integer
O(n)
NeetCode 150
Pattern: Hash Table / Set - Use a HashSet/Unordered Set to track seen numbers.
Sparse Arrays
O(N + M)
HackerRank
Pattern: Hash Table, Frequency Counter - Use a Hash Map to count input string frequencies in O(N), then lookup queries in O(1).
Max Element in Array
N/A
Smart Interviews
Pattern: Linear Traversal / Simple Scan - Initialize a variable to the smallest possible value and iterate through the array, updating the maximum value encountered.
The Missing Number
N/A
Custom
Pattern: Summation/XOR Logic - Use the arithmetic series formula (N*(N+1)/2) to find the expected sum, and subtract the actual sum of the array elements to find the missing number.
Odd and Even Sum
N/A
Custom
Pattern: Conditional Summation - Use a single linear pass to check each element's parity and accumulate separate sums for odd and even numbers.
Find Duplicate Number in Array
N/A
Smart Interviews
Pattern: Cycle Detection (Floyd's Tortoise and Hare) - Treat the array as a linked list where the index i points to the value nums[i]. A duplicate creates a cycle.
Number Distribution (Frequency Count)
N/A
Smart Interviews
Pattern: Frequency Counting / Hashing - Use a hash map to count the occurrences of each number. Then, iterate through the map to find the counts of required numbers.
Triangle Validator
N/A
Smart Interviews
Pattern: Geometry / Inequality Rule - Check the triangle inequality theorem: the sum of the lengths of any two sides of a triangle must be greater than the length of the third side.
Arithmetic Operators
N/A
Smart Interviews
Pattern: Conditional Logic / Switch - Read two numbers and a character operator. Use conditional logic (if/else or switch) to perform the correct operation.
Arithmetic Progression Check
N/A
Smart Interviews
Pattern: Sequence Check / Difference - Calculate the difference between the first two elements. Then, iterate through the rest of the array, checking if the difference between all consecutive pairs is constant.
Factorial
N/A
Smart Interviews
Pattern: Iteration / Recursion - Use an iterative loop starting from 1 up to N, multiplying the result at each step. Must handle data type overflow for large N.
Natural Numbers Sum
N/A
Smart Interviews
Pattern: Arithmetic Series Formula - Use Gauss's formula, $S = rac{N(N+1)}{2}$, to calculate the sum in constant time.
Matrix Row and Column Sums
O(N*M)
Smart Interviews
Pattern: Streaming Input / 1D Array Simulation - Calculate Row Sums by streaming and Column Sums using an auxiliary 1D array.
Lower Triangle Sum
N/A
Smart Interviews
Pattern: Index-based Traversal / Conditionals - Iterate through the matrix and only sum elements where the row index (i) is greater than or equal to the column index (j), i.e., i >= j.
Submatrix Sum
O(NΒ²)
Custom/Smart Interviews
Pattern: Range Query / 2D Prefix Sum (Optimized) - Brute force sum for small N (O(N^2)) or 2D Prefix Sum for optimization (O(1) query).
Filled and Hollow Rectangle
O(N*M)
Custom
Pattern: Basic Nested Loops - Use two nested loops (i for rows, j for columns). For Hollow, add a conditional check for boundaries.
Half Diamond Pattern
O(NΒ²)
Custom
Pattern: Symmetry Combination - Print the pattern in two halves: the increasing part (top) and the decreasing part (bottom).
Triangle and Pyramid Patterns
O(NΒ²)
Custom
Pattern: Row-Index Dependent Printing - Use the row index (i) to determine the number of characters or spaces to print in the inner loop.
Odd Even Index
N/A
Smart Interviews
Pattern: Index-based Conditional Traversal - Iterate through the string index and check the parity (i % 2) of the index to route the character to the odd or even result string.
Digit String Check
N/A
Smart Interviews
Pattern: Character Type Check - Iterate through the string and use a built-in character method (e.g., isdigit() or Character.isDigit()) to check if every character is a numerical digit.
Letter Coverage (Pangram Check)
N/A
Smart Interviews
Pattern: Boolean Array / Frequency Hashing - Use a fixed-size boolean array (size 26) to mark the presence of each letter (a-z) encountered during a single pass.
Vowels and Consonants
N/A
Smart Interviews
Pattern: Character Set Check - Use a predefined set (HashSet in Java/C++, set in Python) of vowels for fast O(1) lookups during a single string traversal.
Compress String (Run-Length Encoding)
N/A
Smart Interviews
Pattern: Run-Length Encoding / Two Pointers - Use a two-pointer approach (read pointer and write pointer) to count consecutive identical characters and replace the sequence with the character followed by the count.