0% found this document useful (0 votes)
5 views47 pages

Arrays

The document is a comprehensive list of algorithmic problems and concepts categorized into various data structures and algorithms such as Arrays, Strings, Linked Lists, Stacks, Binary Trees, Graphs, Dynamic Programming, Tries, Heaps, and Greedy Algorithms. Each category includes specific problems, techniques, and methods to solve them, providing a structured approach to understanding and implementing algorithms. This resource serves as a guide for learners and practitioners to enhance their problem-solving skills in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views47 pages

Arrays

The document is a comprehensive list of algorithmic problems and concepts categorized into various data structures and algorithms such as Arrays, Strings, Linked Lists, Stacks, Binary Trees, Graphs, Dynamic Programming, Tries, Heaps, and Greedy Algorithms. Each category includes specific problems, techniques, and methods to solve them, providing a structured approach to understanding and implementing algorithms. This resource serves as a guide for learners and practitioners to enhance their problem-solving skills in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

ARRAYS

Left Rotate an array by one place Left rotate an array by D places Move Zeros to end

Linear Search Find the Union Find missing number in an array

Maximum Consecutive Ones Find the number that appears once, and Longest subarray with given sum K
other numbers twice (positives)
Longest subarray with sum K (Positives + 2Sum Problem Sort an array of 0's 1's and 2's
Negatives)

Majority Element (>n/2 times) Kadane's Algorithm, maximum subarray Print subarray with maximum subarray sum
sum

Stock Buy and Sell Rearrange the array in alternating positive Next Permutation
and negative items
Leaders in an Array problem Longest Consecutive Sequence in an Array Set Matrix Zeros

Rotate Matrix by 90 degrees Print the matrix in spiral manner Count subarrays with given sum

Pascal's Triangle Majority Element (n/3 times) 3-Sum Problem


4-Sum Problem Largest Subarray with 0 Sum Count number of subarrays with given xor K

Merge Overlapping Subintervals Merge two sorted arrays without extra space Find the repeating and missing number

Count Inversions Reverse Pairs Maximum Product Subarray


BINARY SEARCH

Binary Search to find X in sorted array Implement Bound Search Insert Position

Floor/Ceil in Sorted Array Find the first or last occurrence of a given Count occurrences of a number in a sorted
number in a sorted array array with duplicates

Search in Rotated Sorted Array I Search in Rotated Sorted Array II Find minimum in Rotated Sorted Array
Find out how many times has an array been Single element in a Sorted Array Find peak element
rotated

Find square root of a number in log n Find the Nth root of a number using binary Koko Eating Bananas
search

Minimum days to make M bouquets Find the smallest Divisor Capacity to Ship Packages within D Days
Kth Missing Positive Number Aggressive Cows Book Allocation Problem

Split array - Largest Sum Painter's partition Minimize Max Distance to Gas Station

Median of 2 sorted arrays Kth element of 2 sorted arrays Find the row with maximum number of 1's
Search in a 2 D matrix Search in a row and column wise sorted Find Peak Element (2D Matrix)
matrix

Matrix Median
STRINGS

Remove outermost Paranthesis Reverse words in a given string / Palindrome Largest odd number in a string
Check

Longest Common Prefix Isomorphic String check whether one string is a rotation of another

Check if two strings are anagram of each other Sort Characters by frequency Maximum Nesting Depth of Paranthesis
Roman Number to Integer and vice versa Implement Atoi Count Number of Substrings

Longest Palindromic Substring [Do it without DP] Sum of Beauty of all substring Reverse Every Word in A String
LINKED LIST

Inserting a node in LinkedList Deleting a node in LinkedList Find the length of the linkedlist

Search an element in the LL Introduction to DLL Insert a node in DLL

Delete a node in DLL Reverse a DLL Middle of a LinkedList [TortoiseHare Method]


Reverse a LinkedList [Iterative] Reverse a LL [Recursive] Detect a loop in LL

Find the starting point in LL Length of Loop in LL Check if LL is palindrome or not

Segrregate odd and even nodes in LL Remove Nth node from the back of the LL Delete the middle node of LL
Sort LL Sort a LL of 0's 1's and 2's by changing links Find the intersection point of Y LL

Add 1 to a number represented by LL Add 2 numbers in LL Delete all occurrences of a key in DLL

Find pairs with given sum in DLL Remove duplicates from sorted DLL Reverse LL in group of given size K
Generate all binary strings Generate Parenthesis Print all subsequences / Power Set

Learn All Patterns of Subsequences (Theory) Count all subsequences with sum K Check if there exists a subsequence with sum K

Combination Sum Combination Sum-II Subset Sum-I


Subset Sum-II Combination Sum-III Letter Combinations of a Phone Number

Palindrome Partitioning Word Search N Queen

Rat in a Maze Word Break M Coloring Problem


Sudoku Solver Expression Add Operators
STACK

Implement Stack using Arrays Implement Queue using Arrays Implement Stack using Queue

Implement Queue using Stack Implement Stack using Linked List Implement Queue using Linked List

Check for Balanced Parenthesis Implement Min Stack Infix to Postfix Conversion
Prefix to Infix Conversion Prefix to Postfix Conversion Postfix to Prefix Conversion

Postfix to Infix Infix to Prefix Next Greater Element

Next Greater Element 2 Next Smaller Element Number of NGEs to the Right
Trapping Rain Water Sum of Subarray Minimum Asteroid Collision

Sum of Subarray Ranges Remove K Digits Largest Rectangle in Histogram

Maximal Rectangles Sliding Window Maximum Stock Span Problem


The Celebrity Problem LRU Cache LFU Cache
BINARY TREE

Height of a Binary Tree Check if the Binary tree is height-balanced or not Diameter of Binary Tree

Maximum path sum Check if two trees are identical or not Zig Zag Traversal of Binary Tree

Boundary Traversal of Binary Tree Vertical Order Traversal of Binary Tree Top View of Binary Tree
Bottom View of Binary Tree Right/Left View of Binary Tree Symmetric Binary Tree

Root to Node Path in Binary Tree LCA in Binary Tree Maximum width of a Binary Tree

Check for Children Sum Property Print all the Nodes at a distance of K in a Binary Minimum time taken to BURN the Binary Tree
Tree from a Node
Count total Nodes in a COMPLETE Binary Tree Requirements needed to construct a Unique Construct Binary Tree from inorder and preorder
Binary Tree | Theory

Construct the Binary Tree from Postorder and Serialize and deserialize Binary Tree Morris Preorder Traversal of a Binary Tree
Inorder Traversal

Morris Inorder Traversal of a Binary Tree Flatten Binary Tree to LinkedList


Introduction to Binary Search Tree Search in a Binary Search Tree Find Min/Max in BST

Ceil in a Binary Search Tree Floor in a Binary Search Tree Insert a given Node in Binary Search Tree

Delete a Node in Binary Search Tree Find K-th smallest/largest element in BST Check if a tree is a BST or BT
LCA in Binary Search Tree Construct a BST from a preorder traversal Inorder Successor/Predecessor in BST

Merge 2 BST's Two Sum In BST | Check if there exists a pair Recover BST | Correct BST with two nodes
with Sum K swapped

Largest BST in Binary Tree


GRAPHS

Graph and Types Graph Representation | C++ Graph Representation | Java

Connected Components | Logic Explanation BFS DFS

Number of provinces (leetcode) Connected Components Problem in Matrix Rotten Oranges


Flood fill Cycle Detection in unirected Graph (bfs) Cycle Detection in undirected Graph (dfs)

0/1 Matrix (Bfs Problem) Surrounded Regions (dfs) Number of Enclaves [flood fill implementation -
multisource]

Word ladder – 1 Word ladder - 2 Number of Distinct Islands [dfs multisource]


Bipartite Graph (DFS) Cycle Detection in Directed Graph (DFS) Topo Sort

Kahn's Algorithm Cycle Detection in Directed Graph (BFS) Course Schedule - I

Course Schedule - II Find eventual safe states Alien dictionary


Shortest Path in UG with unit weights Shortest Path in DAG Djisktra's Algorithm

Why priority Queue is used in Djisktra's Shortest path in a binary maze Path with minimum effort
Algorithm

Cheapest flights within k stops Network Delay time Number of ways to arrive at destination
Minimum steps to reach end from start by Bellman Ford Algorithm Floyd Warshal Algorithm
performing multiplication and mod operations
with array elements

Find the city with the smallest number of Minimum Spanning Tree Prim's Algorithm
neighbors in a threshold distance

Disjoint Set [Union by Rank] Disjoint Set [Union by Size] Kruskal's Algorithm
Number of operations to make network connected Most stones removed with same rows or columns Accounts merge

Number of island II Making a Large Island Swim in rising water

Bridges in Graph Articulation Point Kosaraju's Algorithm


DYNAMIC PROGRAMMING

Dynamic Programming Introduction Climbing Stars Frog Jump(DP-3)

Frog Jump with k distances(DP-4) Maximum sum of non-adjacent elements (DP 5) House Robber (DP 6)

Ninja's Training (DP 7) Grid Unique Paths : DP on Grids (DP8) Grid Unique Paths 2 (DP 9)
Minimum path sum in Grid (DP 10) Minimum path sum in Triangular Grid (DP 11) Minimum/Maximum Falling Path Sum (DP-12)

3-d DP : Ninja and his friends (DP-13) Subset sum equal to target (DP- 14) Partition Equal Subset Sum (DP- 15)

Partition Set Into 2 Subsets With Min Absolute Count Subsets with Sum K (DP - 17) Count Partitions with Given Difference (DP - 18)
Sum Diff (DP- 16)
Assign Cookies Minimum Coins (DP - 20) Target Sum (DP - 21)

Coin Change 2 (DP - 22) Unbounded Knapsack (DP - 23) Rod Cutting Problem | (DP - 24)

Longest Common Subsequence | (DP - 25) Print Longest Common Subsequence | (DP - 26) Longest Common Substring | (DP - 27)
Longest Palindromic Subsequence | (DP-28) Minimum insertions to make string palindrome | Minimum Insertions/Deletions to Convert String |
DP-29 (DP- 30)

Shortest Common Supersequence | (DP - 31) Distinct Subsequences| (DP-32) Edit Distance | (DP-33)

Wildcard Matching | (DP-34) Best Time to Buy and Sell Stock |(DP-35) Buy and Sell Stock - II|(DP-36)
Buy and Sell Stocks III|(DP-37) Buy and Stock Sell IV |(DP-38) Buy and Sell Stocks With Cooldown|(DP-39)

Buy and Sell Stocks With Transaction Fee|(DP- Matrix Chain Multiplication|(DP-48) Matrix Chain Multiplication | Bottom-Up|(DP-49)
40)

Minimum Cost to Cut the Stick|(DP-50) Burst Balloons|(DP-51) Evaluate Boolean Expression to True|(DP-52)
Palindrome Partitioning - II|(DP-53) Partition Array for Maximum Sum|(DP-54) Maximum Rectangle Area with all 1's|(DP-55)

Count Square Submatrices with All Ones|(DP-56)


TRIE

Implement Trie - 2 (Prefix Tree) Longest String with All Prefixes Number of Distinct Substrings in a String

Bit PreRequisites for TRIE Problems Maximum XOR of two numbers in an array Maximum XOR With an Element From Array
STRINGS(NEW)

Minimum number of bracket reversals needed to Count and say Hashing In Strings | Theory
make an expression balanced

Rabin Karp Z-Function KMP algo / LPS(pi) array

Shortest Palindrome Longest happy prefix Count palindromic subsequence in given string
Longest Substring Without Repeating Characters Max Consecutive Ones III Fruit Into Baskets

Longest Repeating Character Replacement Binary Subarray With Sum Count Number of Nice Subarrays

Number of Substrings Containing All Three Maximum Points You Can Obtain From Cards Longest Substring with At Most K Distinct
Characters Characters
Subarray with K Different Integers Minimum Window Substring Minimum Window Subsequence
HEAPS
Check if an array represents a min-heap or not Convert min Heap to max Heap Kth largest element in an array [use priority
queue]

Kth smallest element in an array [use priority Sort K sorted array Merge M sorted Lists
queue]

Replace each array element by its corresponding Task Scheduler Hands of Straights
rank
Design twitter Connect n ropes with minimal cost Kth largest element in a stream of running
integers

Maximum Sum Combination Find Median from Data Stream K most frequent elements
GREEDY ALGORITHM

Assign Cookies Fractional Knapsack Problem Greedy algorithm to find minimum number of
coins

Lemonade Change Valid Paranthesis Checker N meetings in one room

Jump Game Jump Game 2 Minimum number of platforms required for a


railway
Job sequencing Problem Candy Program for Shortest Job First (or SJF) CPU
Scheduling

Program for Least Recently Used (LRU) Page Insert Interval Merge Intervals
Replacement Algorithm

Non-overlapping Intervals
SORTING

Selection Sort Bubble Sort Insertion Sort

Merge Sort Recursive Bubble Sort Recursive Insertion Sort

Quick Sort

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy