This repository contains implementations of various design patterns commonly used in data structures and algorithms. Each pattern is accompanied by examples and explanations to help you understand their usage and benefits.
The Frequency Counter Pattern is a technique used to compare two or more sets of data by counting the frequency of distinct elements. It is particularly useful in solving problems that involve comparing and analyzing the frequency of elements in arrays, strings, or other data structures.
- Checking if two strings are anagrams.
- Finding if an array contains duplicate elements.
- Determining if two arrays are permutations of each other.
Two/Multiple pointers is an extremely common technique used to solve array and string problems. It involves having two integer variables that both move along an iterable. In this article, we are focusing on arrays and strings. This means we will have two integers, usually named something like i and j, or left and right which each represent an index of the array or string.
- Counting unique values in array.
- Returning sum of elements === 0 in array.
The sliding window pattern involves maintaining a set of elements within a "window" of a fixed size that slides through the input data, one element at a time. This pattern is particularly useful for solving problems that require finding subarrays, sublists, or subsequences that meet certain conditions.
- find the maximum sum of a subarray of a given size.
Working On
Happy coding! 🚀