0% found this document useful (0 votes)
88 views

Common DSA Coding Patterns Asked in Interviews

DSA questions
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

Common DSA Coding Patterns Asked in Interviews

DSA questions
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Common DSA Coding Patterns Asked in Interviews

(Youtube Playlists, Websites & Practice Questions also included)

Pattern Example Problems YouTube Videos

Two Pointers 1. Two Sum in a sorted array. 1. https://www.youtube.com/watch?v=cQ1Oz


2. Remove duplicates from a sorted array. 4ckceM&t=162s
2. https://www.youtube.com/watch?v=Fm_p9
lJ4Z_8&t=16s

Fast and Slow Pointers 1. Detect a cycle in a linked list. 1. https://www.youtube.com/watch?v=354J8


2. Find the middle node of a linked list. 3hX7RI
2. https://www.youtube.com/watch?v=7LjQ5
7RqgEc

Sliding Window 1. Maximum sum subarray of size K. 1. https://www.youtube.com/watch?v=Ktpqe


2. Longest substring without repeating characters. N0Goro
2. https://www.youtube.com/watch?v=-zSxTJ
kcdAo

Divide and Conquer 1. Implement quicksort or mergesort. 1. https://www.youtube.com/watch?v=ogjf7O


2. Find the maximum subarray sum. RKfd8
2. https://www.youtube.com/watch?v=w_KE
ocd__20

In-place Reversal of a 1. Reverse a linked list. 1. https://www.youtube.com/watch?v=D2vI2


Linked List 2. Reverse the first k nodes of a linked list. DNJGd8
2. https://www.youtube.com/watch?v=lIar1sk
cQYI

Modified Binary Search 1. Search in a rotated sorted array. 1. https://www.youtube.com/watch?v=U8XE


2. Find the 1st or last occurrence of an element in Nwh8Oy8
a sorted array. 2. https://www.youtube.com/watch?v=4sQL7
R5ySUU

Cyclic Sort 1. Sort an array containing numbers from 1 to n. 1. https://www.youtube.com/watch?v=eKIj_1


2. Find the missing number in an array. 2-2kk
2. https://www.youtube.com/watch?v=WnPL
SRLSANE

Matrix Traversal 1. Search an element in a sorted matrix where 1. https://www.youtube.com/watch?v=_reu46


each row and column is sorted. LJtyk

Merge Intervals 1. Merge overlapping intervals. 1. https://www.youtube.com/watch?v=44H3c


2. Insert a new interval into a list of EC2fFM
non-overlapping intervals. 2. https://www.youtube.com/watch?v=A8NU
OmlwOlM

Two Heaps 1. Find the median of a stream of numbers. 1. https://www.youtube.com/watch?v=itmhH


2. Implement a sliding window median. WaHupI
2. https://www.youtube.com/watch?v=NT5Lp
5vaMm0

Top k Elements 1. Find the kth largest element in an array. 1. https://www.youtube.com/watch?v=XEmy


2. Top k frequent elements in an array. 13g1Qxc
2. https://www.youtube.com/watch?v=YPTq
KIgVk-k
K-way Merge 1. Merge k sorted arrays or lists. 1. https://www.youtube.com/watch?v=q5a5O
2. Find the median of two sorted arrays of iGbT6Q
different sizes. 2. https://www.youtube.com/watch?v=C2rRz
z-JDk8

Breadth First Search 1. Shortest path in an unweighted graph from 1. https://www.youtube.com/watch?v=C4gxo


(BFS) source to destination. TaI71U

Depth First Search 1. Path Sum in a binary tree. 1. https://www.youtube.com/watch?v=LSKQ


(DFS) 2. Detect cycle in a directed graph. yOz_P8I
3. Find all paths between 2 nodes. 2. https://www.youtube.com/watch?v=9twcm
tQj4DU
3. https://www.youtube.com/watch?v=TrElo
QBv7WQ

Topological Sort 1. Schedule tasks with dependencies (course 1. https://www.youtube.com/watch?v=EgI5n


schedule problem). U9etnU
2. Alien Dictionary problem. 2. https://www.youtube.com/watch?v=6kTZY
vNNyps

Subsets 1. Generate all possible subsets of a set. 1. https://www.youtube.com/watch?v=REOH


2. Subsets with duplicates. 22Xwdkk
2. https://www.youtube.com/watch?v=Vn2v6
ajA7U0

Bitwise XOR 1. Find the missing number where all numbers 1. https://www.youtube.com/watch?v=5nMG
from 1 to n are present except one. Y4VUoRY

Trie 1. Implement autocomplete (prefix search). 1. https://www.youtube.com/watch?v=oobqo


2. Find if a string is a prefix of any word in a CJlHA0
sentence. 2. https://www.youtube.com/watch?v=iWNFp
4YL4I0

Backtracking 1. N-Queens problem. 1. https://www.youtube.com/watch?v=Ph95I


2. Generate all valid parentheses combinations. HmRp5M
3. Sudoku Solver. 2. https://www.youtube.com/watch?v=s9fokU
qJ76A
3. https://www.youtube.com/watch?v=tRj4Vl
VTat8

Monotonic Stack 1. Find the next greater element for each element 1. https://www.youtube.com/watch?v=e7XQL
in an array. tOQM3I
2. Largest Rectangle in Histogram. 2. https://www.youtube.com/watch?v=zx5Sw
9130L0

Fibonacci Numbers 1. Calculate the nth Fibonacci number efficiently. 1. https://www.youtube.com/watch?v=xAYJc


9fu7xA

0/1 Knapsack 1. Solve the classic 0/1 knapsack problem. 1. https://www.youtube.com/watch?v=GqOm


JHQZivw

Palindromic 1. Find the longest palindromic subsequence. 1. https://www.youtube.com/watch?v=6i_T5k


Subsequence 2. Count palindromic subsequences in a string. kfv4A
2. https://www.youtube.com/watch?v=vlbA8o
UxSV0

Longest Common 1. Find the longest common substring between 1. https://www.youtube.com/watch?v=_wP9


Substring two strings. mWNPL5w
2. Shortest Supersequence problem. 2. https://www.youtube.com/watch?v=xElxAu
BcvsU
YouTube Videos to learn DSA

● https://youtube.com/playlist?list=PLgUwDviBIf0oF6QL8m22w1hIDC1vJ_BHz&si=QB
JU4WYSBnWR44GY
● https://youtube.com/playlist?list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&si=K
sQ8xnnnwELNCzjD
● https://youtube.com/playlist?list=PLAXnLdrLnQpRcveZTtD644gM9uzYqJCwr&si=I5Bl
5EoqADwGJMet
● https://youtube.com/playlist?list=PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi&si=pfpS
MaRHl8_hEcRi

Websites to learn DSA

● https://takeuforward.org/strivers-a2z-dsa-course/strivers-a2z-dsa-course-sheet-2/
● https://www.geeksforgeeks.org/dsa-tutorial-learn-data-structures-and-algorithms/
● https://www.w3schools.com/dsa/

Practice Questions

● https://github.com/krishnadey30/LeetCode-Questions-CompanyWise
● https://www.geeksforgeeks.org/top-100-data-structure-and-algorithms-dsa-interview-
questions-topic-wise/
● https://leetcode.com/discuss/interview-question/4258631/Top-100-DSA-Interview-Qu
estions
● https://www.w3schools.com/dsa/dsa_exercises.php
● https://youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ&si=EH
WCY9lff1snVEXf

You might also like