50 Coding Patterns Every Placement Student Must Know (With Examples)
- Two Pointers
- Reverse String – TCS Ninja
- Two Sum II – Capgemini
- Reverse String – TCS Ninja
- Sliding Window
- Maximum Subarray – Wipro
- Longest Substring Without Repeating Characters – Infosys
- Maximum Subarray – Wipro
- Fast & Slow Pointer
- Linked List Cycle – Wipro
- Middle of the Linked List – TCS Digital
- Linked List Cycle – Wipro
- Merge Intervals
- Merge Intervals – Infosys SP Role
- Merge Intervals – Infosys SP Role
- Binary Search
- Binary Search – Capgemini
- Search Insert Position – Wipro
- Binary Search – Capgemini
- Hashing/Frequency Map
- Two Sum – TCS CodeVita
- Majority Element – Infosys
- Two Sum – TCS CodeVita
- Prefix Sum
- Subarray Sum Equals K – Capgemini
- Subarray Sum Equals K – Capgemini
- Stack-Based Pattern
- Valid Parentheses – Infosys
- Daily Temperatures – Wipro
- Valid Parentheses – Infosys
- Recursion + Backtracking
- Subsets – Wipro Elite
- Permutations – TCS
- Subsets – Wipro Elite
- Bit Manipulation
- Single Number – TCS Digital
- Greedy Algorithm
- Jump Game – Capgemini
- Gas Station – Infosys SP
- Dynamic Programming
- Climbing Stairs – Wipro
- House Robber – Capgemini
- Union-Find (Disjoint Set)
- Number of Connected Components – TCS CodeVita
- BFS (Breadth-First Search)
- Binary Tree Level Order Traversal – Infosys
- DFS (Depth-First Search)
- Number of Islands – Capgemini
- Topological Sort
- Course Schedule – Advanced Infosys role
- Trie-Based Pattern
- Implement Trie – Coding contests (Capgemini)
- Matrix Traversal
- Spiral Matrix – Wipro
- Monotonic Stack
- Next Greater Element – Capgemini
- Heap/Priority Queue
Kth Largest Element in an Array – Infosys
21. In-place Reversal of Linked List
- Reverse Linked List – Infosys
- Linked List Cycle Detection
- Linked List Cycle II – Capgemini
- Flood Fill Algorithm
- Flood Fill – Wipro
- Permutations and Combinations
- Letter Case Permutation – TCS Digital
- Subsets Pattern
- Subsets II – Infosys SP
- Rotate Array/String Pattern
- Rotate Array – Capgemini
- Minimum/Maximum in Sliding Window (Deque)
- Sliding Window Maximum – Advanced Wipro roles
- Backtracking with Constraints
- N-Queens – Infosys HackWithInfy
- Greedy with Sorting
- Minimum Number of Arrows to Burst Balloons – Capgemini
- Segment Tree Pattern (Range Query)
- Range Sum Query – Mutable – Advanced TCS CodeVita
- Kadane’s Algorithm
- Maximum Subarray – Wipro
- Two Heaps
- Find Median from Data Stream – Capgemini
- Binarization Techniques
- Find Minimum in Rotated Sorted Array – TCS Digital
- Recursive Tree Traversals
- Binary Tree Inorder Traversal – Infosys
- Iterative Tree Traversals
- Binary Tree Postorder Traversal – Capgemini
- LCA (Lowest Common Ancestor)
- Diameter of a Tree
- Diameter of Binary Tree – Infosys
- Count Paths Pattern
- Unique Paths – TCS
- Graph Coloring
- Is Graph Bipartite? – Capgemini
- K-way Merge
- Merge k Sorted Lists – Infosys
- Cycle Detection in Graph
- Course Schedule II – Capgemini
- Top K Elements Pattern
- Top K Frequent Elements – Wipro
- Jump Game / Reachability
- Jump Game II – Infosys
- Median in Stream (Two Heap)
- Find Median from Data Stream – Capgemini
- Longest Palindromic Substring
- Longest Palindromic Substring – TCS Digital
- Rabin Karp / Rolling Hash
- Implement strStr() – TCS Ninja
- Shortest Path Algorithm (Dijkstra)
- Network Delay Time – Infosys
- Bellman-Ford Algorithm
- Cheapest Flights Within K Stops – Capgemini
- Floyd Warshall Algorithm
- Minimum Distance Between Two Cities – Advanced Coding Tests
- Minimax / Game Theory Pattern
Predict the Winner – Infosys SP Role
Fast Revision DSA Sheet: 60 Questions to Crack Any Service-Based Company
Easy Level (For Basics)
- Reverse a String – TCS Ninja
- Two Sum – Wipro
- Palindrome Check – Infosys
- [Find Max and Min in Array] – Capgemini
- [Fibonacci using Recursion] – Infosys
- [Linear Search] – TCS
- Binary Search – Wipro
- Remove Duplicates from Sorted Array – TCS
- Check Anagram – Capgemini
- Merge Two Sorted Arrays – Infosys
🔹 Medium Level (Must-Solve)
- Two Sum II – Input Sorted – Wipro
- Rotate Array – Capgemini
- Majority Element – Infosys
- Linked List Cycle – TCS Digital
- Middle of Linked List – Wipro
- Intersection of Two Arrays – TCS
- Climbing Stairs (DP) – Infosys
- Valid Parentheses – Capgemini
- Longest Common Prefix – Wipro
- Count 1s in Binary – Infosys
- Subarray Sum Equals K – Capgemini
- Kth Largest Element – Infosys
- Find Peak Element – TCS
- Move Zeroes – Wipro
- Isomorphic Strings – Infosys
- Power of Two – Capgemini
- Missing Number – TCS
- First Unique Character in String – Wipro
- Detect Capital – Infosys
- Relative Ranks – Capgemini
🔹 Advanced Level (Optional but Strong Boost)
- Merge Intervals – Infosys SP
- Search in Rotated Sorted Array – TCS Digital
- Longest Substring Without Repeating Characters – Wipro
- Unique Paths – TCS
- Implement Trie – Capgemini
- Flood Fill – Wipro
- Subsets – Infosys
- Letter Case Permutation – TCS
- Find the Difference – Wipro
- N-Queens – Infosys
🔹 Interview-Driven Coding Questions
- Reverse Linked List – Infosys
- Palindrome Linked List – TCS
- Maximum Depth of Binary Tree – Wipro
- Diameter of Binary Tree – Infosys
- Lowest Common Ancestor – Capgemini
- Course Schedule – Infosys
- Find the Duplicate Number – TCS Digital
- Top K Frequent Elements – Capgemini
- Valid Anagram – Infosys
- House Robber – TCS
🔹 Bonus 10 Questions (Speed Practice)
- Fizz Buzz – TCS
- Maximum Product of Three Numbers – Infosys
- Longest Palindromic Substring – TCS Digital
- Binary Tree Inorder Traversal – Capgemini
- Find All Duplicates – Infosys
- Jump Game – Wipro
- Majority Element II – TCS
- Spiral Matrix – Capgemini
- Find Pivot Index – Infosys
Best 30 LeetCode Problems for TCS, Wipro, Capgemini Interviews
How to Use This List
- These questions are divided by topic.
- Practice 1–2 problems daily.
- Use the links to open them directly on LeetCode.
🔹 Arrays (8 Questions)
- Two Sum – Find indices of two numbers that add up to a target.
- Remove Duplicates from Sorted Array – Work with sorted arrays.
- Best Time to Buy and Sell Stock – Learn single pass logic.
- Move Zeroes – Rearranging elements in-place.
- Maximum Subarray – Understand Kadane’s Algorithm.
- Find the Duplicate Number – Asked in Capgemini & Wipro.
- Merge Sorted Array – Combine two sorted arrays.
- Majority Element – Simple frequency-based logic.
🔹 Strings (6 Questions)
- Valid Anagram – Sort or use hashmaps.
- Valid Palindrome – Clean and compare strings.
- Longest Common Prefix – Basic string matching.
- Implement strStr() – Asked in TCS Ninja.
- Reverse String – Two-pointer technique.
- First Unique Character in a String – Learn frequency-based scanning.
🔹 Searching and Sorting (4 Questions)
- Binary Search – Basic search logic.
- Search Insert Position – Easy variation of binary search.
- Sort Colors – 3-pointer Dutch Flag problem.
- Intersection of Two Arrays – Use sets effectively.
🔹 Recursion and Backtracking (3 Questions)
- Fibonacci Number – Recursion basics.
- Climbing Stairs – Common in Wipro.
- Subsets – Learn how backtracking works.
🔹 Hashing and Maps (3 Questions)
- Two Sum – Again, shows use of hashmaps.
- Group Anagrams – Work with map of lists.
- Isomorphic Strings – Track mapping between characters.
🔹 Math and Logic (3 Questions)
- Power of Two – Bitwise or loop-based logic.
- Add Digits – Basic loop question.
- Happy Number – Asked in Capgemini coding round.
🔹 Miscellaneous (3 Questions)
- Valid Parentheses – Stack-based matching.
- Merge Two Sorted Lists – Learn linked list basics.
- Linked List Cycle – Fast-slow pointer method.
Final Tips
- Don’t try to solve all 30 in one go.
Understand the logic, not just the syntax.
How to Master Arrays, Strings & Recursion for Placements in 30 Days
30-Day Plan to Master These Topics
Week 1: Get Comfortable with Arrays (Day 1–7)
Concepts to Learn:
- What is an array?
- Basic operations: traversal, insertion, deletion
- Finding min, max, sum, average
Practice Questions:
- Reverse an array
- Find max and min
- Sort an array
- Move all zeroes to the end
Tip: Try solving 2 easy problems daily from platforms like LeetCode, HackerRank, or Campusmonk.
Week 2: Master Array Patterns (Day 8–14)
Concepts to Learn:
- Two-pointer approach
- Sliding window technique
- Hashing in arrays
Practice Questions:
- Two sum
- Subarray with given sum
- Count pairs with given sum
- Find missing number
Tip: Focus on understanding the logic, not memorizing code. Write dry runs on paper.
Week 3: Learn String Basics + Patterns (Day 15–21)
Concepts to Learn:
- String manipulation basics
- Frequency count using arrays/dictionaries
- Palindrome and anagram logic
Practice Questions:
- Check if string is palindrome
- Remove duplicates
- Count vowels and consonants
- Find maximum occurring character
Tip: Start writing your own functions instead of using built-in ones immediately.
Week 4: Start Recursion (Day 22–27)
Concepts to Learn:
- What is recursion?
- Base case and recursive call
- Factorial, Fibonacci using recursion
Practice Questions:
- Factorial of a number
- Sum of digits using recursion
- Reverse a string using recursion
- Print subsets of a string
Tip: Recursion is tricky at first. Try drawing recursion trees to visualize the flow.
Final Days: Mock + Revision (Day 28–30)
Use these 3 days to:
- Revise all topics
- Re-solve the problems you got wrong earlier
- Take 2 mock coding rounds (30 mins each)
Tip: Don’t start new topics now. Focus on what you’ve already covered. Build confidence.
DSA Roadmap for Service-Based Companies – Focused for 5–10 LPA Roles
Step 1: Understand the Pattern (Day 1)
Before you jump into DSA, know what’s actually asked.
Common Topics in Tests/Interviews:
- Arrays
- Strings
- Sorting & Searching
- Recursion
- HashMap
- Stack & Queue (Basics)
- Time & Space Complexity
Start slow. Don’t rush.
🔹 Step 2: Arrays & Strings (Days 2–7)
These two topics alone cover 40–50% of questions asked in TCS, Wipro, and Infosys.
What to do:
- Learn basics: syntax, loops, array operations
- Practice 10 easy problems first
- Focus on patterns: two-pointer, sliding window, frequency count
Popular Questions:
- Reverse an array
- Move all zeros to end
- Check if string is palindrome
- Find duplicates in array
Use platforms like LeetCode (Easy filter), HackerRank, or our Campusmonk Sheets.
🔹 Step 3: Recursion + Basic Patterns (Days 8–12)
You don’t need to master deep recursion, just the basics.
What to cover:
- Factorial
- Fibonacci
- Print subsets of string
- Power of a number
Why this matters: Many pattern-based questions (like backtracking) start with recursion logic.
🔹 Step 4: Sorting, Searching & HashMaps (Days 13–17)
Understand sorting logic, not just how to write it.
Topics to learn:
- Bubble, Selection, Insertion Sort
- Binary Search (on array)
- HashMap basics (count frequency, find pairs)
Most Asked Problems:
- Two Sum (using HashMap)
- Sort array of 0s, 1s, 2s
- Frequency of each element
- Find missing number in array
🔹 Step 5: Practice Problem Solving (Days 18–25)
Now that you know concepts, let’s apply.
Create a habit:
- 2 Easy + 1 Medium question daily
- Time yourself
- Use Campusmonk tracker or LeetCode explore
Topics to revise:
- Arrays & Strings
- Sorting
- Hashing
- Recursion basics
🔹 Step 6: Learn Stack & Queue Basics (Days 26–28)
No need to go deep. Just the fundamentals are enough.
Learn:
- Stack operations (push, pop)
- Queue operations (enqueue, dequeue)
- Balanced parentheses
- Prefix/Postfix expression (just intro level)
These come in aptitude + technical rounds sometimes.
🔹 Step 7: Final Revision + Mock Tests (Days 29–30)
Plan:
- Revise all solved problems
- Attempt 2 mock tests (Campusmonk, PrepInsta, HackerRank)
- Solve 1 HR + 1 Aptitude + 1 Coding mock paper
Tips:
- Focus on speed + accuracy
- Note down mistakes in a separate notebook
- Don’t study new topics on last 2 days
✅ What You Can Skip (for Now)
- Trees, Graphs, and DP (for service-based roles)
- Deep OOPs concepts
- System design, advanced SQL
15 Most Repeated Coding Questions in Infosys, TCS & Wipro Interviews
The 15 Most Repeated Questions (With Easy-to-Understand Code Snippets)
Each code snippet below is simplified and beginner-friendly. Suitable for students from any background.
1. Two Sum Problem
Problem: Given an array and a target, find two numbers that add up to the target.
Python:
def two_sum(nums, target):
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[i] + nums[j] == target:
return [i, j]
2. Check Palindrome
Problem: Check if a string is the same forward and backward.
Python:
def is_palindrome(s):
return s == s[::-1]
3. Anagram Check
Problem: Check if two strings have the same letters.
Python:
def is_anagram(s1, s2):
return sorted(s1) == sorted(s2)
4. Remove Duplicates from Array
Python:
def remove_duplicates(arr):
unique = []
for num in arr:
if num not in unique:
unique.append(num)
return unique
5. Fibonacci Series
Python:
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
print(a, end=' ')
a, b = b, a + b
6. Reverse a String
Python:
def reverse_string(s):
return s[::-1]
7. Factorial (Recursion)
Python:
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)
8. Missing Number in Array
Python:
def find_missing(arr, n):
expected_sum = n * (n + 1) // 2
actual_sum = sum(arr)
return expected_sum - actual_sum
9. Maximum Occurring Character
Python:
def max_char(s):
freq = {}
for char in s:
freq[char] = freq.get(char, 0) + 1
return max(freq, key=freq.get)
10. Count Vowels and Consonants
Python:
def count_vowels_consonants(s):
vowels = 'aeiouAEIOU'
v = 0
c = 0
for i in s:
if i.isalpha():
if i in vowels:
v += 1
else:
c += 1
return v, c
11. Sort Array of 0s, 1s, 2s
Python:
def sort_zeros_ones_twos(arr):
return sorted(arr)
12. Second Largest Element
Python:
def second_largest(arr):
arr = list(set(arr)) # remove duplicates
arr.sort()
return arr[-2] if len(arr) >= 2 else None
13. Find Duplicates in Array
Python:
def find_duplicates(arr):
seen = set()
duplicates = []
for num in arr:
if num in seen:
if num not in duplicates:
duplicates.append(num)
else:
seen.add(num)
return duplicates
14. Check Prime Number
Python:
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
15. Balanced Parentheses
Python:
Top 150 Coding Questions Asked in Service-Based Company Exams (2023–2025)
Here is a list of 150 actual questions from placement and technical rounds carried out by leading service-based companies such as TCS, Infosys, Wipro, Accenture, Capgemini, Cognizant, HCL, and IBM. The questions are perfect to practice logic, data structures, and algorithms in order to enhance your placement performance.
Basic Level (1–50)
- Reverse a string. (TCS – 2023)
- Number is palindrome. (Infosys – 2024)
- Factorial recursively. (Wipro – 2023)
- Missing number in array. (Capgemini – 2024)
- Check anagram of strings. (Accenture – 2024)
- Bubble sort. (Infosys – 2023)
- Binary to decimal. (TCS – 2024)
- Print Fibonacci series. (Wipro – 2024)
- Second largest in array. (Capgemini – 2023)
- Count vowels in string. (Accenture – 2023)
- Check prime number. (Infosys – 2025)
- Check Armstrong number. (TCS – 2023)
- GCD of two numbers. (Wipro – 2023)
- Power function without library. (Capgemini – 2024)
- Reverse singly linked list. (Accenture – 2024)
- Binary search. (Infosys – 2024)
- Detect loop in linked list. (TCS – 2025)
- Longest substring without repeating characters. (Wipro – 2024)
- Check power of 2. (Capgemini – 2023)
- Merge two sorted arrays. (Accenture – 2023)
- Find LCM. (Infosys – 2023)
- Stack using two queues. (TCS – 2024)
- Valid palindrome excluding symbols. (Wipro – 2023)
- Count occurrence of elements. (Capgemini – 2025)
- String to title case. (Accenture – 2025)
- Rotate array by k positions. (Infosys – 2024)
- Balanced parentheses validation. (TCS – 2023)
- Implement Queue using two stacks. (Wipro – 2024)
- Missing and repeating number. (Capgemini – 2024)
- Kadane’s algorithm. (Accenture – 2024)
- Sort array of 0s, 1s, 2s. (Cognizant – 2024)
- Number of digits in an integer. (Infosys – 2024)
- Armstrong numbers in range. (Wipro – 2023)
- Array elements sum. (TCS – 2023)
- Factorial through loop. (Capgemini – 2025)
- Two numbers without temp swapping. (Accenture – 2024)
- Linear search. (Infosys – 2023)
- Add two matrices. (Wipro – 2024)
- Print prime numbers within a range. (HCL – 2024)
- Print pattern of stars. (TCS – 2023)
- Words in sentence count. (Infosys – 2024)
- Leap year check. (Wipro – 2023)
- Duplicates in array remove. (Capgemini – 2023)
- Remove white spaces from string. (Accenture – 2025)
- Sum of digits of a number. (IBM – 2025)
- Find median of array. (TCS – 2024)
- Count set bits in integer. (Infosys – 2024)
- Transpose of matrix. (Wipro – 2023)
- Calculate power with bitwise. (Capgemini – 2025)
- Merge two strings alternatively. (Accenture – 2023)
——————
Intermediate Level (51–100)
- Next greater element. (TCS – 2023)
- Reverse the words in sentence. (Wipro – 2023)
- Find leaders in array. (Capgemini – 2024)
- Valid parenthesis with stack. (Infosys – 2024)
- Infix to postfix conversion. (Accenture – 2024)
- Evaluate postfix expression. (HCL – 2023)
- Intersection of two arrays. (TCS – 2023)
- Union of two arrays. (IBM – 2025)
- Find duplicate elements. (Wipro – 2024)
- Check for Armstrong in array. (Capgemini – 2025)
- Spiral print of matrix. (Accenture – 2023)
- Diagonal sum of matrix. (Infosys – 2024)
- Rearrange array in zigzag. (TCS – 2023)
- Longest common prefix. (Wipro – 2023)
- Sort string alphabetically. (Capgemini – 2024)
- Count uppercase/lowercase chars. (Infosys – 2025)
- Find max occurring character. (Accenture – 2025)
- Convert decimal to binary. (TCS – 2024)
- Convert binary to octal. (Wipro – 2023)
- Replace space with %20. (Capgemini – 2025)
- Zigzag traversal of binary tree. (Infosys – 2024)
- Validate Sudoku. (Accenture – 2024)
- Count islands in grid. (IBM – 2023)
- Reverse array in-place. (TCS – 2023)
- First non-repeating character. (Wipro – 2024)
- Subset sum problem. (Capgemini – 2023)
- Check palindrome linked list. (Infosys – 2023)
- Flatten a linked list. (Accenture – 2023)
- Detect cycle in graph. (HCL – 2023)
- Topological sort. (TCS – 2024)
- Print boundary of binary tree. (Wipro – 2023)
- Binary tree height. (Capgemini – 2025)
- Reverse stack recursively. (Infosys – 2025)
- Queue using linked list. (Accenture – 2025)
- LRU cache implementation. (TCS – 2023)
- Longest increasing subsequence. (Wipro – 2024)
- Count inversions in array. (Capgemini – 2025)
- Implement trie. (Infosys – 2024)
- Minimum coins to make amount. (Accenture – 2023)
- Word break problem. (IBM – 2025)
- Matrix rotation by 90 degrees. (TCS – 2024)
- Binary tree to DLL. (Wipro – 2024)
- Generate balanced parentheses. (Capgemini – 2025)
- Shortest path in matrix. (Accenture – 2025)
- N-th Fibonacci using DP. (Infosys – 2024)
- Bellman-Ford algorithm. (TCS – 2023)
- Floyd-Warshall algorithm. (Wipro – 2024)
- Dijkstra’s algorithm. (Capgemini – 2024)
- Heap sort. (Infosys – 2025)
- Top K frequent elements. (Accenture – 2023)
—————
Advanced Level (101–150)
- Maximum product subarray. (Wipro – 2024)
- Rotate linked list. (Capgemini – 2025)
- Detect intersection of linked lists. (TCS – 2023)
- Celebrity problem using stack. (Infosys – 2024)
- Count set bits using Brian Kernighan’s algo. (Accenture – 2024)
- Maximum sum path in matrix. (HCL – 2025)
- Implement max heap. (TCS – 2024)
- Largest rectangle in histogram. (Wipro – 2023)
- Trapping rain water problem. (Capgemini – 2025)
- Sudoku solver. (Accenture – 2025)
- Snake and ladder game simulation. (Infosys – 2024)
- Find median of data stream. (TCS – 2023)
- Sliding window maximum. (Wipro – 2024)
- Serialize and deserialize binary tree. (Capgemini – 2023)
- Jump game. (Infosys – 2025)
- Count number of ways to climb stairs. (Accenture – 2025)
- Wildcard pattern matching. (TCS – 2024)
- Regex matching. (Wipro – 2023)
- N-Queens problem. (Capgemini – 2025)
- Count number of BSTs. (Infosys – 2023)
- Implement segment tree. (Accenture – 2025)
- Lowest common ancestor in binary tree. (HCL – 2024)
- Inorder successor in BST. (TCS – 2024)
- Interleave K sorted lists. (Wipro – 2024)
- Find peak element. (Capgemini – 2023)
- Diameter of binary tree. (Infosys – 2024)
- Longest palindromic substring. (Accenture – 2023)
- Count distinct subsequences. (IBM – 2025)
- Matrix chain multiplication. (TCS – 2023)
- Minimum window substring. (Wipro – 2024)
- Edit distance. (Capgemini – 2025)
- Word ladder. (Infosys – 2024)
- Evaluation of expression tree. (Accenture – 2024)
- Bit manipulation problems. (TCS – 2024)
- Disjoint set (Union Find). (Wipro – 2023)
- Max path sum in binary tree. (Capgemini – 2023)
- Job scheduling with deadlines. (Infosys – 2025)
- Course schedule (topological). (Accenture – 2025)
- Number of smaller elements to right. (TCS – 2024)
- Burst balloons problem. (Wipro – 2023)
- Max points from cards. (Capgemini – 2024)
- Find centroid of a tree. (Infosys – 2024)
- Inversion count using merge sort. (Accenture – 2023)
- Convert BST to greater sum tree. (TCS – 2023)
- Palindrome partitioning. (Wipro – 2024)
- Decode ways (DP). (Capgemini – 2025)
- Longest valid parentheses. (Infosys – 2024)
- Distinct paths in a matrix. (Accenture – 2025)
- Count ways to make change. (TCS – 2024)
- Largest subarray with 0 sum. (Wipro – 2023)