50 Coding Patterns Every Placement Student Must Know (With Examples)

  1. Two Pointers
  2. Sliding Window
  3. Fast & Slow Pointer
  4. Merge Intervals
  5. Binary Search
  6. Hashing/Frequency Map
  7. Prefix Sum
  8. Stack-Based Pattern
  9. Recursion + Backtracking
  10. Bit Manipulation
  1. Greedy Algorithm
  1. Dynamic Programming
  1. Union-Find (Disjoint Set)
  1. BFS (Breadth-First Search)
  1. DFS (Depth-First Search)
  1. Topological Sort
  1. Trie-Based Pattern
  1. Matrix Traversal
  1. Monotonic Stack
  1. Heap/Priority Queue

Kth Largest Element in an Array – Infosys

   21. In-place Reversal of Linked List

  1. Linked List Cycle Detection
  1. Flood Fill Algorithm
  1. Permutations and Combinations
  1. Subsets Pattern
  1. Rotate Array/String Pattern
  1. Minimum/Maximum in Sliding Window (Deque)
  1. Backtracking with Constraints
  1. Greedy with Sorting
  1. Segment Tree Pattern (Range Query)
  1. Kadane’s Algorithm
  1. Two Heaps
  1. Binarization Techniques
  1. Recursive Tree Traversals
  1. Iterative Tree Traversals
  1. LCA (Lowest Common Ancestor)
  1. Diameter of a Tree
  1. Count Paths Pattern
  1. Graph Coloring
  1. K-way Merge
  1. Cycle Detection in Graph
  1. Top K Elements Pattern
  1. Jump Game / Reachability
  1. Median in Stream (Two Heap)
  1. Longest Palindromic Substring
  1. Rabin Karp / Rolling Hash
  1. Shortest Path Algorithm (Dijkstra)
  1. Bellman-Ford Algorithm
  1. Floyd Warshall Algorithm
  1. 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)

  1. Reverse a String – TCS Ninja
  2. Two Sum – Wipro
  3. Palindrome Check – Infosys
  4. [Find Max and Min in Array] – Capgemini
  5. [Fibonacci using Recursion] – Infosys
  6. [Linear Search] – TCS
  7. Binary Search – Wipro
  8. Remove Duplicates from Sorted Array – TCS
  9. Check Anagram – Capgemini
  10. Merge Two Sorted Arrays – Infosys

🔹 Medium Level (Must-Solve)

  1. Two Sum II – Input Sorted – Wipro
  2. Rotate Array – Capgemini
  3. Majority Element – Infosys
  4. Linked List Cycle – TCS Digital
  5. Middle of Linked List – Wipro
  6. Intersection of Two Arrays – TCS
  7. Climbing Stairs (DP) – Infosys
  8. Valid Parentheses – Capgemini
  9. Longest Common Prefix – Wipro
  10. Count 1s in Binary – Infosys
  11. Subarray Sum Equals K – Capgemini
  12. Kth Largest Element – Infosys
  13. Find Peak Element – TCS
  14. Move Zeroes – Wipro
  15. Isomorphic Strings – Infosys
  16. Power of Two – Capgemini
  17. Missing Number – TCS
  18. First Unique Character in String – Wipro
  19. Detect Capital – Infosys
  20. Relative Ranks – Capgemini

🔹 Advanced Level (Optional but Strong Boost)

  1. Merge Intervals – Infosys SP
  2. Search in Rotated Sorted Array – TCS Digital
  3. Longest Substring Without Repeating Characters – Wipro
  4. Unique Paths – TCS
  5. Implement Trie – Capgemini
  6. Flood Fill – Wipro
  7. Subsets – Infosys
  8. Letter Case Permutation – TCS
  9. Find the Difference – Wipro
  10. N-Queens – Infosys

🔹 Interview-Driven Coding Questions

  1. Reverse Linked List – Infosys
  2. Palindrome Linked List – TCS
  3. Maximum Depth of Binary Tree – Wipro
  4. Diameter of Binary Tree – Infosys
  5. Lowest Common Ancestor – Capgemini
  6. Course Schedule – Infosys
  7. Find the Duplicate Number – TCS Digital
  8. Top K Frequent Elements – Capgemini
  9. Valid Anagram – Infosys
  10. House Robber – TCS

🔹 Bonus 10 Questions (Speed Practice)

  1. Fizz Buzz – TCS
  2. Maximum Product of Three Numbers – Infosys
  3. Longest Palindromic Substring – TCS Digital
  4. Binary Tree Inorder Traversal – Capgemini
  5. Find All Duplicates – Infosys
  6. Jump Game – Wipro
  7. Majority Element II – TCS
  8. Spiral Matrix – Capgemini
  9. Find Pivot Index – Infosys
  1. Check If N and Its Double Exist – TCS

Best 30 LeetCode Problems for TCS, Wipro, Capgemini Interviews

How to Use This List

🔹 Arrays (8 Questions)

  1. Two Sum – Find indices of two numbers that add up to a target.
  2. Remove Duplicates from Sorted Array – Work with sorted arrays.
  3. Best Time to Buy and Sell Stock – Learn single pass logic.
  4. Move Zeroes – Rearranging elements in-place.
  5. Maximum Subarray – Understand Kadane’s Algorithm.
  6. Find the Duplicate Number – Asked in Capgemini & Wipro.
  7. Merge Sorted Array – Combine two sorted arrays.
  8. Majority Element – Simple frequency-based logic.

🔹 Strings (6 Questions)

  1. Valid Anagram – Sort or use hashmaps.
  2. Valid Palindrome – Clean and compare strings.
  3. Longest Common Prefix – Basic string matching.
  4. Implement strStr() – Asked in TCS Ninja.
  5. Reverse String – Two-pointer technique.
  6. First Unique Character in a String – Learn frequency-based scanning.

🔹 Searching and Sorting (4 Questions)

  1. Binary Search – Basic search logic.
  2. Search Insert Position – Easy variation of binary search.
  3. Sort Colors – 3-pointer Dutch Flag problem.
  4. Intersection of Two Arrays – Use sets effectively.

🔹 Recursion and Backtracking (3 Questions)

  1. Fibonacci Number – Recursion basics.
  2. Climbing Stairs – Common in Wipro.
  3. Subsets – Learn how backtracking works.

🔹 Hashing and Maps (3 Questions)

  1. Two Sum – Again, shows use of hashmaps.
  2. Group Anagrams – Work with map of lists.
  3. Isomorphic Strings – Track mapping between characters.

🔹 Math and Logic (3 Questions)

  1. Power of Two – Bitwise or loop-based logic.
  2. Add Digits – Basic loop question.
  3. Happy Number – Asked in Capgemini coding round.

🔹 Miscellaneous (3 Questions)

  1. Valid Parentheses – Stack-based matching.
  2. Merge Two Sorted Lists – Learn linked list basics.
  3. Linked List Cycle – Fast-slow pointer method.

Final Tips

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:

Practice Questions:

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:

Practice Questions:

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:

Practice Questions:

Tip: Start writing your own functions instead of using built-in ones immediately.

Week 4: Start Recursion (Day 22–27)

Concepts to Learn:

Practice Questions:

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:

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:

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:

Popular Questions:

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:

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:

Most Asked Problems:


🔹 Step 5: Practice Problem Solving (Days 18–25)

Now that you know concepts, let’s apply.

Create a habit:

Topics to revise:


🔹 Step 6: Learn Stack & Queue Basics (Days 26–28)

No need to go deep. Just the fundamentals are enough.

Learn:

These come in aptitude + technical rounds sometimes.


🔹 Step 7: Final Revision + Mock Tests (Days 29–30)

Plan:

Tips:


✅ What You Can Skip (for Now)

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 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)

  1. Reverse a string. (TCS – 2023)
  2. Number is palindrome. (Infosys – 2024)
  3. Factorial recursively. (Wipro – 2023)
  4. Missing number in array. (Capgemini – 2024)
  5. Check anagram of strings. (Accenture – 2024)
  6. Bubble sort. (Infosys – 2023)
  7. Binary to decimal. (TCS – 2024)
  8. Print Fibonacci series. (Wipro – 2024)
  9. Second largest in array. (Capgemini – 2023)
  10. Count vowels in string. (Accenture – 2023)
  11. Check prime number. (Infosys – 2025)
  12. Check Armstrong number. (TCS – 2023)
  13. GCD of two numbers. (Wipro – 2023)
  14. Power function without library. (Capgemini – 2024)
  15. Reverse singly linked list. (Accenture – 2024)
  16. Binary search. (Infosys – 2024)
  17. Detect loop in linked list. (TCS – 2025)
  18. Longest substring without repeating characters. (Wipro – 2024)
  19. Check power of 2. (Capgemini – 2023)
  20. Merge two sorted arrays. (Accenture – 2023)
  21. Find LCM. (Infosys – 2023)
  22. Stack using two queues. (TCS – 2024)
  23. Valid palindrome excluding symbols. (Wipro – 2023)
  24. Count occurrence of elements. (Capgemini – 2025)
  25. String to title case. (Accenture – 2025)
  26. Rotate array by k positions. (Infosys – 2024)
  27. Balanced parentheses validation. (TCS – 2023)
  28. Implement Queue using two stacks. (Wipro – 2024)
  29. Missing and repeating number. (Capgemini – 2024)
  30. Kadane’s algorithm. (Accenture – 2024)
  31. Sort array of 0s, 1s, 2s. (Cognizant – 2024)
  32. Number of digits in an integer. (Infosys – 2024)
  33. Armstrong numbers in range. (Wipro – 2023)
  34. Array elements sum. (TCS – 2023)
  35. Factorial through loop. (Capgemini – 2025)
  36. Two numbers without temp swapping. (Accenture – 2024)
  37. Linear search. (Infosys – 2023)
  38. Add two matrices. (Wipro – 2024)
  39. Print prime numbers within a range. (HCL – 2024)
  40. Print pattern of stars. (TCS – 2023)
  41. Words in sentence count. (Infosys – 2024)
  42. Leap year check. (Wipro – 2023)
  43. Duplicates in array remove. (Capgemini – 2023)
  44. Remove white spaces from string. (Accenture – 2025)
  45. Sum of digits of a number. (IBM – 2025)
  46. Find median of array. (TCS – 2024)
  47. Count set bits in integer. (Infosys – 2024)
  48. Transpose of matrix. (Wipro – 2023)
  49. Calculate power with bitwise. (Capgemini – 2025)
  50. Merge two strings alternatively. (Accenture – 2023)

——————

Intermediate Level (51–100)

  1. Next greater element. (TCS – 2023)
  2. Reverse the words in sentence. (Wipro – 2023)
  3. Find leaders in array. (Capgemini – 2024)
  4. Valid parenthesis with stack. (Infosys – 2024)
  5. Infix to postfix conversion. (Accenture – 2024)
  6. Evaluate postfix expression. (HCL – 2023)
  7. Intersection of two arrays. (TCS – 2023)
  8. Union of two arrays. (IBM – 2025)
  9. Find duplicate elements. (Wipro – 2024)
  10. Check for Armstrong in array. (Capgemini – 2025)
  11. Spiral print of matrix. (Accenture – 2023)
  12. Diagonal sum of matrix. (Infosys – 2024)
  13. Rearrange array in zigzag. (TCS – 2023)
  14. Longest common prefix. (Wipro – 2023)
  15. Sort string alphabetically. (Capgemini – 2024)
  16. Count uppercase/lowercase chars. (Infosys – 2025)
  17. Find max occurring character. (Accenture – 2025)
  18. Convert decimal to binary. (TCS – 2024)
  19. Convert binary to octal. (Wipro – 2023)
  20. Replace space with %20. (Capgemini – 2025)
  21. Zigzag traversal of binary tree. (Infosys – 2024)
  22. Validate Sudoku. (Accenture – 2024)
  23. Count islands in grid. (IBM – 2023)
  24. Reverse array in-place. (TCS – 2023)
  25. First non-repeating character. (Wipro – 2024)
  26. Subset sum problem. (Capgemini – 2023)
  27. Check palindrome linked list. (Infosys – 2023)
  28. Flatten a linked list. (Accenture – 2023)
  29. Detect cycle in graph. (HCL – 2023)
  30. Topological sort. (TCS – 2024)
  31. Print boundary of binary tree. (Wipro – 2023)
  32. Binary tree height. (Capgemini – 2025)
  33. Reverse stack recursively. (Infosys – 2025)
  34. Queue using linked list. (Accenture – 2025)
  35. LRU cache implementation. (TCS – 2023)
  36. Longest increasing subsequence. (Wipro – 2024)
  37. Count inversions in array. (Capgemini – 2025)
  38. Implement trie. (Infosys – 2024)
  39. Minimum coins to make amount. (Accenture – 2023)
  40. Word break problem. (IBM – 2025)
  41. Matrix rotation by 90 degrees. (TCS – 2024)
  42. Binary tree to DLL. (Wipro – 2024)
  43. Generate balanced parentheses. (Capgemini – 2025)
  44. Shortest path in matrix. (Accenture – 2025)
  45. N-th Fibonacci using DP. (Infosys – 2024)
  46. Bellman-Ford algorithm. (TCS – 2023)
  47. Floyd-Warshall algorithm. (Wipro – 2024)
  48. Dijkstra’s algorithm. (Capgemini – 2024)
  49. Heap sort. (Infosys – 2025)
  50. Top K frequent elements. (Accenture – 2023)

—————

Advanced Level (101–150)

  1. Maximum product subarray. (Wipro – 2024)
  2. Rotate linked list. (Capgemini – 2025)
  3. Detect intersection of linked lists. (TCS – 2023)
  4. Celebrity problem using stack. (Infosys – 2024)
  5. Count set bits using Brian Kernighan’s algo. (Accenture – 2024)
  6. Maximum sum path in matrix. (HCL – 2025)
  7. Implement max heap. (TCS – 2024)
  8. Largest rectangle in histogram. (Wipro – 2023)
  9. Trapping rain water problem. (Capgemini – 2025)
  10. Sudoku solver. (Accenture – 2025)
  11. Snake and ladder game simulation. (Infosys – 2024)
  12. Find median of data stream. (TCS – 2023)
  13. Sliding window maximum. (Wipro – 2024)
  14. Serialize and deserialize binary tree. (Capgemini – 2023)
  15. Jump game. (Infosys – 2025)
  16. Count number of ways to climb stairs. (Accenture – 2025)
  17. Wildcard pattern matching. (TCS – 2024)
  18. Regex matching. (Wipro – 2023)
  19. N-Queens problem. (Capgemini – 2025)
  20. Count number of BSTs. (Infosys – 2023)
  21. Implement segment tree. (Accenture – 2025)
  22. Lowest common ancestor in binary tree. (HCL – 2024)
  23. Inorder successor in BST. (TCS – 2024)
  24. Interleave K sorted lists. (Wipro – 2024)
  25. Find peak element. (Capgemini – 2023)
  26. Diameter of binary tree. (Infosys – 2024)
  27. Longest palindromic substring. (Accenture – 2023)
  28. Count distinct subsequences. (IBM – 2025)
  29. Matrix chain multiplication. (TCS – 2023)
  30. Minimum window substring. (Wipro – 2024)
  31. Edit distance. (Capgemini – 2025)
  32. Word ladder. (Infosys – 2024)
  33. Evaluation of expression tree. (Accenture – 2024)
  34. Bit manipulation problems. (TCS – 2024)
  35. Disjoint set (Union Find). (Wipro – 2023)
  36. Max path sum in binary tree. (Capgemini – 2023)
  37. Job scheduling with deadlines. (Infosys – 2025)
  38. Course schedule (topological). (Accenture – 2025)
  39. Number of smaller elements to right. (TCS – 2024)
  40. Burst balloons problem. (Wipro – 2023)
  41. Max points from cards. (Capgemini – 2024)
  42. Find centroid of a tree. (Infosys – 2024)
  43. Inversion count using merge sort. (Accenture – 2023)
  44. Convert BST to greater sum tree. (TCS – 2023)
  45. Palindrome partitioning. (Wipro – 2024)
  46. Decode ways (DP). (Capgemini – 2025)
  47. Longest valid parentheses. (Infosys – 2024)
  48. Distinct paths in a matrix. (Accenture – 2025)
  49. Count ways to make change. (TCS – 2024)
  50. Largest subarray with 0 sum. (Wipro – 2023)