Algorithms
Computational solutions with defined complexity
#Arrays11
Find All Duplicates
Find all elements that appear more than once in an array using frequency counting.
Find Duplicate
Find the first duplicate element that appears in an array using a hash set for efficient lookup.
Find Missing Number
Find the missing number in a sequence from 1 to n using mathematical sum formula.
Longest Increasing Subsequence
Find the length of the longest increasing subsequence in an array using dynamic programming.
Maximum Subarray Sum
Find the maximum sum of a contiguous subarray using Kadane's algorithm.
Merge Intervals
Merge overlapping intervals into consolidated ranges. A classic algorithm problem used in scheduling, genomics, and calendar applications.
Sliding Window Maximum
Find the maximum value in each sliding window of size k as it moves across the array.
Spiral Matrix
Traverse a 2D matrix in spiral order starting from the top-left corner.
Three Sum
Find all unique triplets in an array that sum to a target value.
Top K Elements
Find the k largest elements in an array using sorting or heap-based approach.
Two Sum
Find indices of two numbers in an array that add up to a target value using a hash map for O(n) time complexity.
#Machine Learning1
#Math10
Digital Root
Calculate the digital root by repeatedly summing digits until a single digit remains.
Factorial
Calculate the factorial of a number (n!) using iterative multiplication.
Fibonacci Sequence
Generate the first N numbers of the Fibonacci sequence where each number is the sum of the two preceding ones.
Greatest Common Divisor
Find the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
Is Prime
Check if a number is a prime number by testing divisibility up to its square root.
Least Common Multiple
Find the least common multiple (LCM) of two numbers using the GCD-based formula.
Modular Exponentiation
Calculate (base^exp) % mod efficiently using binary exponentiation.
Nth Prime
Find the nth prime number using primality testing.
Prime Factors
Find all prime factors of a number using trial division.
Sieve of Eratosthenes
Generate all prime numbers up to n using the Sieve of Eratosthenes algorithm.
#Sorting7
Bubble Sort
Sort an array using the bubble sort algorithm by repeatedly swapping adjacent elements.
Counting Sort
Sort an array of non-negative integers using counting sort for linear time performance.
Heap Sort
Sort an array using the heap sort algorithm with O(n log n) time complexity.
Insertion Sort
Sort an array using the insertion sort algorithm by building a sorted portion one element at a time.
Merge Sort
Sort an array using the merge sort algorithm with O(n log n) time complexity.
Quicksort
Sort an array using the quicksort algorithm with average O(n log n) time complexity.
Selection Sort
Sort an array using the selection sort algorithm by repeatedly finding the minimum element.
#Strings4
Check if Palindrome
Check if a string is a palindrome by comparing characters from both ends.
Levenshtein Distance
Calculate the Levenshtein edit distance between two strings using dynamic programming.
Longest Common Substring
Find the longest contiguous substring that appears in both strings using an iterative approach.
String Similarity
Calculate the similarity percentage between two strings based on edit distance.