DSA Practice
DSA Practice Sheet for Campus Placements
Learn the pattern first, then solve problems in that pattern. Even a new interview question usually follows an old pattern. This sheet has 43 core problems across 11 patterns.
Problem sheet: search and filter
Type a problem name, or choose a pattern, difficulty and company. Clicking a problem opens the practice page in a new tab.
Showing 43 of 43 problems
- #1 · ArraysEasyTwo Sum (opens in new tab)
The journey from brute force to HashMap. The most common interview warm-up.
TCSInfosysWiproAmazon - #2 · ArraysEasyBest Time to Buy and Sell Stock (opens in new tab)
Track a running minimum and solve it in one pass.
TCSAccentureAmazon - #3 · ArraysMediumMaximum Subarray (Kadane's Algorithm) (opens in new tab)
Asked every season. The simplest form of DP.
TCSInfosysCapgeminiAmazon - #4 · ArraysMediumProduct of Array Except Self (opens in new tab)
Prefix and suffix products. Teaches you to think without division.
Amazon - #5 · Two PointersEasyMove Zeroes (opens in new tab)
In-place array updates. A service-company coding round favourite.
TCSWiproCapgemini - #6 · Two PointersEasyValid Palindrome (opens in new tab)
Compare from both ends: strings and two pointers together.
TCSInfosysAccenture - #7 · Two PointersMediumContainer With Most Water (opens in new tab)
Which pointer to move? You must explain the greedy reasoning.
AmazonInfosys - #8 · Two PointersMedium3Sum (opens in new tab)
Sort + two pointers + duplicate handling. Common in product interviews.
Amazon - #9 · Two PointersHardTrapping Rain Water (opens in new tab)
The left-max / right-max classic. Builds Hard-level confidence.
Amazon - #10 · StringsEasyValid Anagram (opens in new tab)
Character frequency counting with a size-26 array.
TCSWiproAccentureCapgemini - #11 · StringsEasyLongest Common Prefix (opens in new tab)
String comparison basics. Appears directly in online tests.
TCSInfosys - #12 · StringsMediumLongest Substring Without Repeating Characters (opens in new tab)
Your entry to sliding window: grow and shrink a window with a set/map.
InfosysAmazon - #13 · StringsMediumReverse Words in a String (opens in new tab)
Split, trim and reverse. Tests how you handle extra spaces.
TCSWiproCapgemini - #14 · HashingEasyContains Duplicate (opens in new tab)
The most direct use of a HashSet. A two-minute question.
TCSAccentureCapgemini - #15 · HashingMediumGroup Anagrams (opens in new tab)
What should the map key be: a sorted string or a count signature?
AmazonInfosys - #16 · HashingMediumTop K Frequent Elements (opens in new tab)
Frequency map + heap or bucket sort. A common follow-up.
Amazon - #17 · Sliding WindowEasyMaximum Average Subarray I (opens in new tab)
A fixed-size window. The first step into sliding window.
TCSWipro - #18 · Sliding WindowMediumMinimum Size Subarray Sum (opens in new tab)
A variable window: when to expand and when to shrink.
InfosysAmazon - #19 · Sliding WindowMediumPermutation in String (opens in new tab)
Window + frequency match. The next level of anagrams.
Amazon - #20 · StackEasyValid Parentheses (opens in new tab)
The number one stack question. Shows up at almost every company.
TCSInfosysWiproAccentureAmazon - #21 · StackMediumMin Stack (opens in new tab)
A design question: how do you keep the minimum in O(1)?
AmazonCapgemini - #22 · StackMediumDaily Temperatures (opens in new tab)
Monotonic stack: the next greater element pattern.
Amazon - #23 · Linked ListEasyReverse a Linked List (opens in new tab)
Pointer reversal. Know both the iterative and recursive versions.
TCSInfosysWiproCapgeminiAmazon - #24 · Linked ListEasyDetect Cycle in a Linked List (opens in new tab)
Floyd's slow-fast pointers. Also asked in viva rounds.
InfosysAccentureAmazon - #25 · Linked ListEasyMerge Two Sorted Lists (opens in new tab)
The dummy node technique. The foundation of merge sort.
TCSWiproAmazon - #26 · Linked ListEasyMiddle of the Linked List (opens in new tab)
Find the middle in one pass. The simplest slow-fast use.
TCSCapgeminiAccenture - #27 · Linked ListHardMerge k Sorted Lists (opens in new tab)
Heap + linked list. A product-company favourite Hard.
Amazon - #28 · TreesEasyMaximum Depth of Binary Tree (opens in new tab)
Your first recursive tree question. Learn the base case.
InfosysCapgeminiAmazon - #29 · TreesEasyInvert Binary Tree (opens in new tab)
Swap left and right. Builds recursion confidence.
AccentureAmazon - #30 · TreesMediumBinary Tree Level Order Traversal (opens in new tab)
BFS with a queue. The template for many tree problems.
InfosysAmazon - #31 · TreesMediumLowest Common Ancestor of a BST (opens in new tab)
Use the BST property to decide: go left or right.
Amazon - #32 · GraphsEasyFlood Fill (opens in new tab)
DFS on a grid. The easiest door into graphs.
InfosysAmazon - #33 · GraphsMediumNumber of Islands (opens in new tab)
Connected components. Very common at product companies.
AmazonInfosys - #34 · GraphsMediumRotting Oranges (opens in new tab)
Multi-source BFS: counting time as levels.
Amazon - #35 · GraphsMediumCourse Schedule (opens in new tab)
Cycle detection + topological sort. Directed graph basics.
Amazon - #36 · Dynamic ProgrammingEasyClimbing Stairs (opens in new tab)
Fibonacci-style DP. Go from recursion to a table.
TCSInfosysAccentureAmazon - #37 · Dynamic ProgrammingMediumHouse Robber (opens in new tab)
Pick / not-pick DP. Many later problems build on this.
InfosysAmazon - #38 · Dynamic ProgrammingMediumCoin Change (opens in new tab)
A form of unbounded knapsack: find the minimum coins.
InfosysAmazon - #39 · Dynamic ProgrammingMediumLongest Increasing Subsequence (opens in new tab)
O(n²) DP with an O(n log n) follow-up. Know both.
Amazon - #40 · Binary SearchEasyBinary Search (opens in new tab)
low, high, mid. Boundary mistakes happen most here.
TCSWiproCapgeminiAccenture - #41 · Binary SearchMediumSearch in Rotated Sorted Array (opens in new tab)
Spotting which half is sorted is the whole problem.
InfosysAmazon - #42 · Binary SearchMediumFind Minimum in Rotated Sorted Array (opens in new tab)
Find the rotation point. Companion to the problem above.
Amazon - #43 · Binary SearchMediumKoko Eating Bananas (opens in new tab)
Binary search on the answer. A new way of thinking.
Amazon
DSA patterns in one line each
Service companies test easy to medium levels. Product companies go up to Trees, Graphs and DP.
Arrays
4 problemsPrefix sums, running max/min and one-pass thinking like Kadane's.
Show only ArraysStrings
4 problemsCharacter counts, reversal and index-based substring handling.
Show only StringsHashing
3 problemsUse a HashMap/HashSet to turn O(n²) into O(n).
Show only HashingTwo Pointers
5 problemsPointers moving inward from both ends, usually on sorted data.
Show only Two PointersSliding Window
3 problemsA fixed or variable window over a contiguous subarray or substring.
Show only Sliding WindowStack
3 problemsBrackets, next greater element and 'remember the previous one' problems.
Show only StackLinked List
5 problemsSlow-fast pointers, dummy nodes and pointer reversal.
Show only Linked ListTrees
4 problemsDFS (recursion) and BFS (queue). Master traversals first.
Show only TreesGraphs
4 problemsBFS/DFS on grids or nodes, a visited array and topological sort.
Show only GraphsDynamic Programming
4 problemsRecursion + memo, then a bottom-up table. Define the state first.
Show only Dynamic ProgrammingBinary Search
4 problemsHalve a sorted search space. It also works on the answer itself.
Show only Binary Search
The Saathi Method
The right way to practise DSA
- 1
Learn the pattern first
Read the pattern idea for 5 minutes, then solve the problems in that pattern.
- 2
Start with brute force
Write whatever works first, state its time complexity, then move towards the optimal solution.
- 3
Solve out loud
Interviews expect you to explain your thinking. Say your approach out loud while you practise.
- 4
Star it, then revise
If a problem takes more than 30 minutes, study the solution and star it. Redo only starred problems at the end of the week.
Your next step
Practise aptitude alongside DSA
Aptitude is the gatekeeper before the coding round. Do 20 timed questions today.