All guides
Coding

DSA for Service Companies: The 15 Patterns That Matter

Team prephasz· 7 Jul 2026· 2 min read

You do not need 500 LeetCode problems to clear a service-company coding round. Master these 15 recurring patterns and you can solve almost anything TCS, Infosys, Wipro or Accenture throw at you.

Most students prepare for coding rounds the wrong way. They grind hundreds of random problems, feel busy, and still freeze when a slightly unfamiliar question appears. The fix is not more problems — it is recognising the small set of patterns that service-company papers reuse every year.

Here are the 15 that cover the overwhelming majority of TCS, Infosys, Wipro, Cognizant, Capgemini and Accenture coding questions.

Arrays and strings

  1. Two pointers — pair sums, reversing, removing duplicates, palindrome checks.
  2. Sliding window — longest substring without repeats, max sum of size k, anagram windows.
  3. Prefix sums — range-sum queries, subarray-sum-equals-k, equilibrium index.
  4. Frequency counting with a hash map — first non-repeating character, majority element, two-sum.
  5. Sorting as a pre-step — merge intervals, meeting rooms, closest pair.

Numbers and math

  1. Digit manipulation — reverse a number, Armstrong/palindrome numbers, sum of digits.
  2. Prime and factor logic — sieve of Eratosthenes, GCD/LCM, factor counting.
  3. Basic recursion — factorial, Fibonacci, power, and their iterative rewrites.

Searching and ordering

  1. Binary search — on a sorted array and on an answer (first/last occurrence, square root).
  2. Greedy choices — activity selection, coin change (canonical), minimising waiting time.

Structures

  1. Stack usage — valid parentheses, next greater element, min-stack.
  2. Queue and BFS — level-order traversal, shortest path in an unweighted grid.
  3. Linked list traversal — reverse, detect a cycle (Floyd), find the middle.
  4. Hashing for de-duplication — intersection of arrays, subarray with a given sum.
  5. Matrix traversal — spiral order, row/column set-to-zero, rotate by 90 degrees.

How to actually use this list

Do not read the list and move on. For each pattern:

  • Solve three problems until the template is muscle memory.
  • Write the recognition trigger in one line — e.g. "contiguous subarray + optimise → sliding window."
  • Re-derive the time and space complexity out loud.

On prephasz, the coding practice is tagged by exactly these patterns, so you can drill the weak ones instead of practising at random. Clear the 15, and the coding round stops being a lottery.

Put this into practice

Drill these exact patterns with adaptive practice, timed mocks and company-wise assessments on prephasz.

Start practising free
DSA for Service Companies: The 15 Patterns That Matter · ZSkillup