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.

Variables & Data Types

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
Conditionals(if-else)

What you should know:

  • Making decisions in code
  • Comparing values

Why this matters:

  • Almost every DSA problem uses conditions
  • Essential for logic building
Loops(for/while)

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
Arrays (Basics)

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.

Largest Element in an Array

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
Second Largest Element in an Array

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
Check if Array is Sorted

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
Remove Duplicates from Sorted Array

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]
Left Rotate Array by One

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]
Move Zeros to End

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]
Linear Search

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
Find Missing Number in an Array

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.

Palindrome Check

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
Reverse a String

Problem Statement:
Reverse the given string.

How to think:

  • Swap characters from both ends
  • Move pointers towards the center

Example:

  • "abcd" β†’ "dcba"
Anagram Check

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
Check Rotation of String

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
Largest Odd Number in a String

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
Longest Common Prefix

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"] β†’ ""
Reverse Words in a String

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"
Isomorphic Strings

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.

What is a Linked List?

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
Types of Linked Lists

Main Types:

  • Singly Linked List
  • Doubly Linked List
  • Circular Linked List

Beginner Focus:
Start with Singly Linked List.

Traverse a 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
Find Length of Linked List

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
Search an Element in Linked List

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
Insert Node at Beginning

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
Insert Node at End

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
Delete Head Node

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.

What is a Stack? (LIFO)

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
Balanced Parenthesis

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
Reverse a String using Stack

Problem Statement:
Reverse a string using stack behavior.

How to think:

  • Push all characters
  • Pop them to reverse order

Example:

  • "abcd" β†’ "dcba"
What is a Queue? (FIFO)

Concept:
Queue follows First In, First Out (FIFO).

Think of:

  • People waiting in line
  • Printer queue

Operations:

  • Enqueue β†’ Add element
  • Dequeue β†’ Remove element
Implement Queue Conceptually

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
Stack using Queue (Conceptual)

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.

Print Numbers from 1 to N

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
Print Numbers from N to 1

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
Sum of First N Natural Numbers

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:

  • N = 4 β†’ 1+2+3+4 = 10
Factorial of a Number

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
Check Palindrome using Recursion

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 1: Increasing Star Pattern

Pattern:

  • *
  • **
  • ***
  • ****

DP Thinking:

  • Row 1 = *
  • Next row = previous row + *

Why important?

  • Shows how current output depends on previous output
Pattern 2: Repeated Number Triangle

Pattern:

  • 1
  • 22
  • 333
  • 4444

DP Thinking:

  • Row depends on row number
  • Each next row grows in size
Pattern 3: Prefix Sum Pattern

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 4: Doubling Count Pattern

Pattern:

  • 1
  • 2
  • 4
  • 8
  • 16

DP Thinking:

  • Next value = previous Γ— 2

What it teaches:

  • Simple recurrence relation
Pattern 5: Pascal Triangle Pattern

Pattern:

  • 1
  • 1 1
  • 1 2 1
  • 1 3 3 1

DP Thinking:

  • Each value depends on two values above it

Why this matters?

  • Base for many DP grid problems
Pattern 6: Stair Count Visualization

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