0% found this document useful (0 votes)
24 views7 pages

# DSA Questions

The document outlines various data structure and algorithm patterns along with representative questions for each category. It covers topics such as arrays, strings, linked lists, stacks, queues, trees, graphs, heaps, hash tables, dynamic programming, recursion, bit manipulation, greedy algorithms, searching and sorting, advanced data structures, and miscellaneous patterns. Each section includes specific problems that exemplify the techniques and strategies associated with that category.

Uploaded by

Yash Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

# DSA Questions

The document outlines various data structure and algorithm patterns along with representative questions for each category. It covers topics such as arrays, strings, linked lists, stacks, queues, trees, graphs, heaps, hash tables, dynamic programming, recursion, bit manipulation, greedy algorithms, searching and sorting, advanced data structures, and miscellaneous patterns. Each section includes specific problems that exemplify the techniques and strategies associated with that category.

Uploaded by

Yash Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

# DSA Patterns with Representative Questions

## Arrays

### Two-pointer Technique


- Two Sum
- Three Sum
- Container With Most Water
- Trapping Rain Water
- Sort Colors
- Remove Duplicates from Sorted Array

### Sliding Window


- Maximum Sum Subarray of Size K
- Longest Substring Without Repeating Characters
- Minimum Size Subarray Sum
- Longest Repeating Character Replacement
- Permutation in String
- Sliding Window Maximum

### Prefix/Suffix Sums


- Range Sum Query
- Subarray Sum Equals K
- Maximum Size Subarray Sum Equals K
- Product of Array Except Self
- Continuous Subarray Sum
- Subarray Product Less Than K

### Kadane's Algorithm


- Maximum Subarray
- Maximum Sum Circular Subarray
- Maximum Product Subarray
- Buy and Sell Stock
- Flip Bits to Maximize Consecutive Ones

### Dutch National Flag Algorithm


- Sort Colors
- Sort Array By Parity
- Move Zeroes
- Wiggle Sort

### Binary Search on Arrays


- Search in Rotated Sorted Array
- Find First and Last Position of Element in Sorted Array
- Search Insert Position
- Find Peak Element
- Find Minimum in Rotated Sorted Array
- Kth Smallest Element in a Sorted Matrix

### Merge Intervals


- Merge Intervals
- Insert Interval
- Non-overlapping Intervals
- Meeting Rooms II
- Minimum Number of Arrows to Burst Balloons

### Matrix Traversal


- Spiral Matrix
- Rotate Image
- Set Matrix Zeroes
- Search a 2D Matrix
- Word Search
- Diagonal Traverse

### Moore's Voting Algorithm


- Majority Element
- Majority Element II
- Find the Celebrity

## Strings

### String Matching


- Implement strStr() (Needle in Haystack)
- Longest Happy Prefix
- Shortest Palindrome
- Repeated String Match

### Trie-based Problems


- Implement Trie
- Word Search II
- Design Add and Search Words Data Structure
- Replace Words
- Word Break
- Palindrome Pairs

### Palindrome Problems


- Longest Palindromic Substring
- Palindromic Substrings
- Valid Palindrome
- Palindrome Partitioning
- Shortest Palindrome

### Anagram Problems


- Valid Anagram
- Group Anagrams
- Find All Anagrams in a String
- Minimum Number of Steps to Make Two Strings Anagram

## Linked Lists

### Slow and Fast Pointers


- Linked List Cycle
- Linked List Cycle II
- Middle of the Linked List
- Happy Number
- Find the Duplicate Number

### Reversal Problems


- Reverse Linked List
- Reverse Linked List II
- Reverse Nodes in k-Group
- Swap Nodes in Pairs
- Palindrome Linked List

### Merge Lists


- Merge Two Sorted Lists
- Merge k Sorted Lists
- Sort List
- Partition List

## Stacks

### Parentheses Problems


- Valid Parentheses
- Longest Valid Parentheses
- Remove Invalid Parentheses
- Minimum Add to Make Parentheses Valid

### Next Greater Element


- Next Greater Element I
- Next Greater Element II
- Daily Temperatures
- Largest Rectangle in Histogram
- Trapping Rain Water

### Expression Problems


- Basic Calculator
- Basic Calculator II
- Evaluate Reverse Polish Notation
- Decode String
- Remove K Digits

## Queues

### BFS Applications


- Binary Tree Level Order Traversal
- Walls and Gates
- Rotting Oranges
- Word Ladder
- Open the Lock

### Sliding Window Maximum


- Sliding Window Maximum
- Maximum Frequency Stack
- Design Snake Game

## Trees

### DFS Traversals


- Binary Tree Inorder Traversal
- Binary Tree Preorder Traversal
- Binary Tree Postorder Traversal
- Construct Binary Tree from Preorder and Inorder Traversal
- Flatten Binary Tree to Linked List

### Path Sum Problems


- Path Sum
- Path Sum II
- Binary Tree Maximum Path Sum
- Diameter of Binary Tree
- Sum Root to Leaf Numbers

### Lowest Common Ancestor


- Lowest Common Ancestor of a Binary Tree
- Lowest Common Ancestor of a Binary Search Tree
- Smallest Common Region
### Tree Views
- Binary Tree Right/Left Side View
- Top View of Binary Tree
- Bottom View of Binary Tree
- Vertical Order Traversal of a Binary Tree

## Graphs

### DFS Applications


- Number of Islands
- Max Area of Island
- Pacific Atlantic Water Flow
- Surrounded Regions
- Clone Graph

### BFS Applications


- Word Ladder
- Shortest Path in Binary Matrix
- Shortest Bridge
- Open the Lock
- Cut Off Trees for Golf Event

### Shortest Path Algorithms


- Network Delay Time
- Cheapest Flights Within K Stops
- Path With Minimum Effort
- Shortest Path in a Grid with Obstacles Elimination

### Topological Sort


- Course Schedule
- Course Schedule II
- Alien Dictionary
- Sequence Reconstruction
- Minimum Height Trees

### Cycle Detection


- Course Schedule
- Redundant Connection
- Find Eventual Safe States
- Graph Valid Tree

### Union-Find
- Number of Connected Components in an Undirected Graph
- Redundant Connection
- Most Stones Removed with Same Row or Column
- Accounts Merge
- Regions Cut By Slashes

## Heaps/Priority Queues

### K-th Element Problems


- Kth Largest Element in an Array
- Kth Smallest Element in a Sorted Matrix
- Find Median from Data Stream
- Top K Frequent Elements
- Sort Characters By Frequency

### Merge K Items


- Merge k Sorted Lists
- Smallest Range Covering Elements from K Lists
- Find K Pairs with Smallest Sums

## Hash Tables

### Sum Problems


- Two Sum
- 3Sum
- 4Sum
- Subarray Sum Equals K
- Contiguous Array
- Continuous Subarray Sum

### Substring Problems


- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Substring with Concatenation of All Words
- Longest Duplicate Substring

### LRU/LFU Cache


- LRU Cache
- LFU Cache
- Design Twitter
- All O`one Data Structure

## Dynamic Programming

### 0/1 Knapsack


- Subset Sum
- Partition Equal Subset Sum
- Target Sum
- Last Stone Weight II
- Ones and Zeroes

### Unbounded Knapsack


- Coin Change
- Coin Change 2
- Integer Break
- Minimum Cost For Tickets
- Rod Cutting

### Longest Common Subsequence


- Longest Common Subsequence
- Shortest Common Supersequence
- Delete Operation for Two Strings
- Uncrossed Lines
- Edit Distance

### Longest Increasing Subsequence


- Longest Increasing Subsequence
- Number of Longest Increasing Subsequence
- Russian Doll Envelopes
- Maximum Height by Stacking Cuboids
- Minimum Number of Removals to Make Mountain Array

### Grid Problems


- Minimum Path Sum
- Unique Paths
- Unique Paths II
- Dungeon Game
- Cherry Pickup

### Stock Problems


- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock II
- Best Time to Buy and Sell Stock III
- Best Time to Buy and Sell Stock IV
- Best Time to Buy and Sell Stock with Cooldown

## Recursion & Backtracking

### Permutations & Combinations


- Permutations
- Permutations II
- Combinations
- Combination Sum
- Letter Combinations of a Phone Number

### Board Problems


- N-Queens
- Sudoku Solver
- Word Search
- Word Search II
- Valid Sudoku

## Bit Manipulation

### Counting Bits


- Counting Bits
- Number of 1 Bits
- Hamming Distance
- Total Hamming Distance
- Bitwise AND of Numbers Range

### XOR Problems


- Single Number
- Single Number II
- Single Number III
- Find the Duplicate Number
- Missing Number

## Greedy Algorithms

### Interval Problems


- Non-overlapping Intervals
- Minimum Number of Arrows to Burst Balloons
- Meeting Rooms II
- Insert Interval
- Merge Intervals

### Job Scheduling


- Task Scheduler
- Course Schedule III
- Maximum Profit in Job Scheduling
- Minimum Number of Work Sessions to Finish the Tasks

## Searching & Sorting


### Binary Search Variations
- First Bad Version
- Search in Rotated Sorted Array
- Search in Rotated Sorted Array II
- Find Minimum in Rotated Sorted Array
- Search a 2D Matrix

### Quick Select


- Kth Largest Element in an Array
- Top K Frequent Elements
- Find K Closest Elements
- K Closest Points to Origin

## Advanced Data Structures

### Trie
- Implement Trie
- Design Add and Search Words Data Structure
- Word Search II
- Stream of Characters
- Map Sum Pairs

### Segment Tree


- Range Sum Query - Mutable
- Count of Range Sum
- Falling Squares
- Rectangle Area II

### Advanced Tree Structures


- Design Skiplist
- My Calendar II
- Exam Room
- All O`one Data Structure

## Miscellaneous Patterns

### Meet in the Middle


- Partition Array Into Two Arrays to Minimize Sum Difference
- Closest Subsequence Sum
- Split Array With Same Average
- Tallest Billboard

### Line Sweep


- Meeting Rooms II
- The Skyline Problem
- Rectangle Area II
- Car Pooling
- Minimum Number of Arrows to Burst Balloons

### Two Heaps


- Find Median from Data Stream
- Sliding Window Median
- IPO
- Find Right Interval

You might also like