DSA Roadmap β Beginner Friendly
π DSA Prerequisites
Before starting DSA problems, you must be comfortable with
these core programming fundamentals.
If any item feels unclear, revise it first.
What you should know:
- How data is stored in memory
- Difference between numbers, characters, strings
- True / False values
Why this matters for DSA:
- Choosing the correct data type avoids errors
- Memory understanding helps in optimization
What you should know:
- Making decisions in code
- Comparing values
Why this matters:
- Almost every DSA problem uses conditions
- Essential for logic building
What you should know:
- Repeating tasks efficiently
- Loop control (start, end, increment)
Why this matters:
- Arrays, strings, linked lists all use loops
- Time complexity depends on loops
What you should know:
- Storing multiple values
- Index-based access
Why this matters:
- Most DSA problems start with arrays
- Base for strings, DP, matrices
π Arrays (Easy β Build Strong Basics)
Arrays are the foundation of DSA.
Most problems are solved by looping, comparing, and tracking values.
Problem Statement:
Given an array, find the largest element.
How to think:
- Start by assuming the first element is the largest
- Compare it with each element
- Update when you find a bigger number
Example:
- Input: [2, 5, 1, 9]
- Output: 9
Problem Statement:
Find the second largest distinct element in the array.
How to think:
- Track the largest value
- Also track the second largest value
- Update carefully when a new larger value is found
Example:
- Input: [10, 20, 15]
- Output: 15
Problem Statement:
Check whether the array elements are in increasing order.
How to think:
- Compare each element with the one before it
- If any element is smaller than previous β not sorted
Example:
- [1, 2, 3, 4] β Sorted
- [1, 3, 2] β Not Sorted
Problem Statement:
Remove duplicate elements from a sorted array.
How to think:
- Because array is sorted, duplicates are adjacent
- Keep only the first occurrence
Example:
- Input: [1,1,2,2,3]
- Output: [1,2,3]
Problem Statement:
Rotate the array left by one position.
How to think:
- Store the first element
- Shift remaining elements to the left
- Place the first element at the end
Example:
- Input: [1,2,3,4]
- Output: [2,3,4,1]
Problem Statement:
Move all zeros to the end without changing order of non-zero elements.
How to think:
- Focus on non-zero elements
- Keep them at the front
- Zeros automatically go to the end
Example:
- Input: [0,1,0,3]
- Output: [1,3,0,0]
Problem Statement:
Find whether a given element exists in the array.
How to think:
- Check each element one by one
- Stop when element is found
Example:
- Array: [4,6,2,8]
- Search: 6 β Found
Problem Statement:
An array contains numbers from 1 to N with one missing number. Find it.
How to think:
- Expected sum of numbers from 1 to N
- Subtract actual sum
Example:
- Input: [1,2,4,5]
- Missing: 3
π Strings (Easy β Build Strong Basics)
String problems focus on character comparison, order, and frequency.
Most string problems use two pointers or counting logic.
Problem Statement:
Check if a string reads the same forward and backward.
How to think:
- Compare first and last characters
- Move inward until the middle
- If any mismatch occurs β not a palindrome
Example:
- "madam" β Palindrome
- "hello" β Not Palindrome
Problem Statement:
Reverse the given string.
How to think:
- Swap characters from both ends
- Move pointers towards the center
Example:
Problem Statement:
Check whether two strings contain the same characters with the same frequency.
How to think:
- Count frequency of each character
- Compare counts for both strings
Example:
- "listen" & "silent" β Anagrams
- "rat" & "car" β Not Anagrams
Problem Statement:
Check if one string is a rotation of another.
How to think:
- Concatenate original string with itself
- Check if second string exists inside it
Example:
- "abcd" & "cdab" β Rotation
- "abcd" & "acbd" β Not Rotation
Problem Statement:
Given a numeric string, find the largest odd-numbered substring.
How to think:
- Scan from right to left
- First odd digit found determines answer
Example:
- "35427" β "35427"
- "4206" β No odd number
Problem Statement:
Find the longest prefix common to all strings in an array.
How to think:
- Start with first string as prefix
- Shorten prefix until it matches others
Example:
- ["flower","flow","flight"] β "fl"
- ["dog","racecar"] β ""
Problem Statement:
Reverse the order of words in a string.
How to think:
- Split string into words
- Rebuild in reverse order
Example:
- "I love DSA" β "DSA love I"
Problem Statement:
Check if characters from one string can map one-to-one to another.
How to think:
- Each character should map to only one character
- Reverse mapping should also be valid
Example:
- "egg" & "add" β Isomorphic
- "foo" & "bar" β Not Isomorphic
π Linked List (Learning β Easy)
Linked List is a linear data structure made of nodes, where each node
contains data and a link to the next node.
Concept:
A linked list is a collection of nodes where each node stores:
- Data (value)
- Address of the next node
Why Linked List?
- Size can change dynamically
- Insertions and deletions are efficient
Example:
- 10 β 20 β 30 β NULL
Main Types:
- Singly Linked List
- Doubly Linked List
- Circular Linked List
Beginner Focus:
Start with Singly Linked List.
Problem Statement:
Visit and read each element of the linked list.
How to think:
- Start from head node
- Move to next node until NULL
Example:
- 10 β 20 β 30 β NULL
- Output: 10 20 30
Problem Statement:
Count the number of nodes in the linked list.
How to think:
- Traverse the list
- Increase count at each node
Example:
- 10 β 20 β 30 β NULL
- Length: 3
Problem Statement:
Check whether a value exists in the linked list.
How to think:
- Traverse the list
- Compare each nodeβs data
Example:
- List: 5 β 8 β 12 β NULL
- Search: 8 β Found
- Search: 7 β Not Found
Problem Statement:
Insert a new node at the start of the linked list.
How to think:
- Create a new node
- Point it to current head
- Update head to new node
Example:
- Before: 10 β 20 β NULL
- Insert 5
- After: 5 β 10 β 20 β NULL
Problem Statement:
Insert a new node at the end of the linked list.
How to think:
- Traverse until last node
- Attach new node to it
Example:
- Before: 10 β 20 β NULL
- Insert 30
- After: 10 β 20 β 30 β NULL
Problem Statement:
Remove the first node from the linked list.
How to think:
- Move head to next node
- Free the old head node
Example:
- Before: 10 β 20 β 30 β NULL
- After: 20 β 30 β NULL
π Stack & Queue (Learning β Easy)
Stack and Queue are linear data structures that follow
specific insertion and removal rules.
Understanding these rules is the key.
Concept:
Stack follows Last In, First Out (LIFO).
Think of:
- Stack of books
- Undo / Redo operations
Operations:
- Push β Add element
- Pop β Remove top element
- Peek β View top element
Problem Statement:
Check whether brackets are properly opened and closed.
How to think:
- Opening bracket β push into stack
- Closing bracket β pop from stack
- If mismatch β invalid
Why important:
- Used in compilers
- Expression evaluation
Example:
- "(())" β Balanced
- "(()" β Not Balanced
Problem Statement:
Reverse a string using stack behavior.
How to think:
- Push all characters
- Pop them to reverse order
Example:
Concept:
Queue follows First In, First Out (FIFO).
Think of:
- People waiting in line
- Printer queue
Operations:
- Enqueue β Add element
- Dequeue β Remove element
Problem Statement:
Understand how elements are added and removed in a queue.
How to think:
- Add at rear
- Remove from front
Example:
- Queue: 10 β 20 β 30
- Remove β 10 removed first
Problem Statement:
Implement stack behavior using queue rules.
How to think:
- Reorder elements after insertion
- Ensure last inserted comes out first
Why useful:
- Tests understanding of both Stack & Queue
π Recursion (Easy β Understand the Flow)
Recursion means a function calling itself.
To understand recursion, always focus on:
Base Case and Recursive Call.
Problem Statement:
Print numbers from 1 to N using recursion.
Why this problem?
- First recursion problem
- Helps understand call stack
How it works:
- Stop when N becomes 0 (base case)
- Print after recursive call returns
Example:
- N = 5 β Output: 1 2 3 4 5
Problem Statement:
Print numbers from N to 1 using recursion.
How it helps:
- Shows how order changes in recursion
How to think:
- Print before recursive call
- Decrease N each time
Example:
- N = 5 β Output: 5 4 3 2 1
Problem Statement:
Calculate sum of numbers from 1 to N.
Why important?
- Shows recursion returning values
How to think:
- Sum of N = N + sum(Nβ1)
- Stop when N becomes 0
Example:
Problem Statement:
Find factorial of a number using recursion.
Why this problem?
- Classic recursion example
How to think:
- Factorial(N) = N Γ factorial(Nβ1)
- Base case at N = 1
Example:
- 5! = 5 Γ 4 Γ 3 Γ 2 Γ 1 = 120
Problem Statement:
Check whether a string is palindrome using recursion.
Why this problem?
- Combines recursion with strings
How to think:
- Compare first and last characters
- Move inward recursively
Example:
- "madam" β Palindrome
- "hello" β Not Palindrome
π Dynamic Programming (Patterns Only β Learn the Thinking)
Dynamic Programming is about building answers step by step.
These pattern problems train you to:
store previous results and reuse them.
Pattern:
DP Thinking:
- Row 1 = *
- Next row = previous row + *
Why important?
- Shows how current output depends on previous output
Pattern:
DP Thinking:
- Row depends on row number
- Each next row grows in size
Pattern:
- 1 β 1
- 2 β 1 2
- 3 β 1 2 3
DP Thinking:
- Each number is built by adding previous numbers
Why useful?
- Base idea for prefix sum DP
Pattern:
DP Thinking:
- Next value = previous Γ 2
What it teaches:
- Simple recurrence relation
Pattern:
DP Thinking:
- Each value depends on two values above it
Why this matters?
- Base for many DP grid problems
Pattern:
- 1 step β 1 way
- 2 steps β 2 ways
- 3 steps β 3 ways
- 4 steps β 5 ways
DP Thinking:
- Ways(n) = Ways(nβ1) + Ways(nβ2)
Why include?
- Visual intro to DP recurrence (no coding)
Created to learn DSA Problems in a simple, easy and structured way.
Reach me out at
βοΈ dev@chandus7.in
Β© 2026 β All rights reserved