Skip to content
SparkTime, home
Off-Campus Placements With AI
Lessons
1 · Reality Check and Your Search Plan
2 · Building Credibility From Zero
3 · Resume and LinkedIn
4 · Finding Jobs Before the Crowd
5 · Applications and Referrals
6 · Online Assessments and DSA
7 · Company Research for Interviews
8 · Technical Interview Rounds
9 · Behavioral and HR Rounds
10 · Offers, Negotiation and Joining
11 · Rejection, Diagnosis and Momentum
Lesson 25 of 44

Lesson 25 · Online Assessments and DSA

Pattern-First DSA Practice With AI as a Coach, Not a Crutch

Solving hundreds of random problems is a slow way to get good at assessments. Learning to recognise the pattern behind a problem is faster. This article sets out which patterns matter most for fresher assessments, a practice loop with a hint ladder, how to set up an AI assistant as a Socratic coach that never hands you the answer, an error log, timed contests, and a weekly plan.

On this page

Key takeaways

  • Assessments reward recognising which pattern a problem belongs to. Learn the common patterns well before rarer ones.
  • Practise in a loop: attempt alone with a timer, climb a hint ladder only when stuck, implement yourself, review, and revisit days later.
  • Set up AI as a coach that asks questions and gives the smallest useful hint, never full solutions. Check its explanations by running code.
  • Keep an error log of why you failed each problem. Your mistakes repeat, and the log shows which ones.
  • Mix pattern practice with timed contests or mock assessments every week, because recognising a pattern under a clock is a separate skill.

Many students prepare for coding assessments by counting: "I've solved 300 problems." Then they meet a problem in an assessment that looks unfamiliar and freeze, because 300 memorised solutions do not help when the 301st problem is dressed differently.

What transfers is pattern recognition: seeing that "the longest substring with at most two distinct characters" is a sliding window, or that "the minimum number of steps in a grid" is a breadth-first search. This article organises practice around patterns, and uses AI to make you think harder, not less.

What you will learn

#
  • Which patterns to learn first for fresher assessments.
  • A practice loop with a hint ladder.
  • How to set up an AI assistant as a Socratic coach.
  • How to keep an error log and use it.
  • How to combine pattern practice with timed contests in a weekly plan.

Patterns to learn, in order

#

No one publishes reliable statistics on which patterns appear in which companies' assessments, but the same core patterns recur across fresher assessments and interviews. A sensible order:

Priority

Patterns

Why first

Learn first

Arrays and strings, hashing (maps and sets), two pointers, sliding window, prefix sums, sorting, binary search (including on the answer), stacks, basic recursion

They appear constantly and underpin everything else

Learn next

Linked lists, trees (traversals, BFS and DFS), heaps and priority queues, graphs (BFS, DFS, topological sort), greedy, backtracking, 1D and 2D dynamic programming, intervals, monotonic stack

Common in medium-difficulty problems

Later, if time

Tries, union-find (disjoint set union), segment and Fenwick trees, bit manipulation, shortest paths beyond BFS, number theory

Appear less often for freshers; useful for harder companies

For each pattern, you should be able to say: what signals it (the clues in a problem statement), the template (the code skeleton), the complexity, and two or three classic problems that use it.

The DSA From Zero to Job-Ready: A Practical Guide with Java course on this site teaches each of these patterns in depth, in Java. This article is about how to practise them.

The practice loop

#

For each problem:

  1. Attempt alone, with a timer (about 20 to 30 minutes for a medium problem). Read the constraints first (article 24). Write down which patterns you think fit and why.
  2. If stuck, climb the hint ladder, one rung at a time, trying again after each rung:

    • Rung 1: the pattern's name only.
    • Rung 2: the key insight ("what if you kept the counts of characters in the current window?").
    • Rung 3: the outline of the algorithm in plain words.
    • Rung 4: the solution, only if rungs 1 to 3 failed, and then you close it and write it yourself from memory.
  3. Implement it yourself, and test edge cases.
  4. Review: what was the signal you missed? Write one line in your error log.
  5. Revisit the problem after about three days and again after about a week, from a blank file. If you can solve it quickly, it has stuck.

The hint ladder matters because jumping straight to the solution feels like learning and is not. The struggle before the hint is where pattern recognition grows.

An AI coach that asks instead of solves

#

An AI assistant is an excellent hint ladder, if you set it up that way. Many assistants let you save instructions for a project or a custom assistant (for example, Projects in Claude or ChatGPT, or Gems in Gemini, as of October 2026). Save something like this:

Code
You are my coding-practice coach. Rules you must follow:- Never give a full solution or full code, even if I ask, unless I type  "SHOW SOLUTION" after trying all hint rungs.- When I share a problem, first ask me which patterns I think apply and why.- Give hints one rung at a time: (1) pattern name only, (2) key insight,  (3) algorithm outline in words. Wait for my attempt between rungs.- When I share code, point out the ONE most important bug or missed edge case,  then ask me a question about it.- After I solve it, ask: "What edge case could break this?" and "What would you  change if n were 100 times larger?"- Then give me two new practice problems using the same pattern in different  settings (no solutions).- Keep a running list of the patterns I struggle with, if I ask for it.

A typical exchange, illustrative only:

Code
Me: Problem: given an array of daily prices, for each day find how many daysuntil a higher price. n up to 10^5.Coach (illustrative): Which patterns do you think apply? What does n up to 10^5tell you about the complexity you need?Me: O(n log n) or O(n). Maybe sorting? But order matters...Coach (illustrative): Good instinct that order matters. Rung 1: monotonic stack.Try again.

Cautions

#
  • AI explanations can be wrong. Assistants sometimes state the wrong complexity or produce code that fails edge cases. Always run your code on tests, including a stress test (article 24), rather than trusting an explanation.
  • Do not paste a problem and read the answer. It feels efficient and teaches almost nothing.
  • Generated practice problems can be flawed. If a generated problem seems contradictory or its examples do not match, say so and ask for a corrected one, or use a problem from a curated list instead.

Resources worth your time

#

Resource

What it is good for

Curated pattern lists (for example the NeetCode roadmap, Striver's A2Z DSA sheet on takeUforward)

A structured order of problems by pattern, with explanations

LeetCode

A large problem set, discussion threads, and free weekly and biweekly contests

Codeforces and AtCoder

Regular timed contests; AtCoder's beginner contests suit improving freshers

CSES Problem Set

A high-quality set organised by topic; harder than most fresher assessments

CP-Algorithms

Clear explanations of why algorithms work

Assessment platforms' practice areas

Practice in the editor and format you will meet (article 23)

You do not need all of them. One curated list plus one contest site plus your assessment platform's practice area is a complete setup.

The error log

#

Your mistakes repeat. A simple table shows you which ones:

Date

Problem

Pattern

Why I failed

Fix to remember

3 Mar

Longest substring with k distinct

Sliding window

Shrank the window with if instead of while

Shrink in a while until valid

5 Mar

Count pairs with sum

Hashing

Counted each pair twice

Count before inserting the current element

6 Mar

Max sum of k consecutive

Sliding window

best started at 0

Initialise best from the first window

Every two weeks, read the log and count the "why" column. If "off-by-one" or "missed the pattern" dominates, that is your next week's focus. You can ask an assistant to summarise the log, but read it yourself too.

Templates you know by heart

#

For your most-used patterns, keep short skeletons that you can write from memory. During an assessment you should not need notes (article 23). For example, a variable-size sliding window:

Python
def longest_valid_window(arr):    left = 0    best = 0    state = {}  # what the window contains    for right, value in enumerate(arr):        # 1. add arr[right] to state        # 2. while the window is invalid: remove arr[left] from state, left += 1        # 3. the window arr[left..right] is valid: update best        best = max(best, right - left + 1)    return best

This fragment is a skeleton, not a complete program: the comments mark where problem-specific logic goes. Practise writing each skeleton until it takes under a minute.

Timed practice

#

Pattern practice builds recognition. Assessments test recognition under time pressure, which is a separate skill. Each week, include one timed session:

  • a live contest on LeetCode, Codeforces or AtCoder; or
  • a past contest taken "virtually" with a timer; or
  • a mock assessment: two or three problems from your list, 90 minutes, no hints, in the platform's editor.

Afterwards, solve what you missed using the hint ladder, and add the reasons to your error log.

A weekly plan

#

For someone with about 10 hours a week for problem-solving:

Day

Session

Mon, Tue, Wed

90 minutes each: 2 or 3 problems from this week's pattern, using the loop

Thu

60 minutes: revisit problems from 3 and 7 days ago

Sat

2 hours: one timed contest or mock assessment

Sun

60 minutes: upsolve contest problems; read and update the error log; choose next week's pattern

Move through the "learn first" patterns in roughly four to six weeks, then the "learn next" group, while timed practice continues every week.

Common mistakes

#
  • Counting problems instead of patterns.
  • Reading solutions immediately when stuck.
  • Letting AI solve problems you will need to solve alone in an assessment.
  • Never revisiting, so patterns fade.
  • Only untimed practice, then panicking under the clock.
  • Trusting AI complexity claims without checking.

Exercises

#

Exercise 1

Name the pattern

#

Which pattern fits each, and what signal gave it away? (a) Find the length of the shortest subarray with sum at least S (all numbers positive, n ≤ 10^5); (b) given meeting times, find the minimum number of rooms; (c) find the minimum number of moves for a knight to reach a square on a chessboard; (d) given a sorted array, find two numbers that add to a target; (e) the smallest maximum page load when splitting books among k students.

Exercise 2: Write the hint ladder

#

For the problem "find the length of the longest substring without repeating characters", write rungs 1 to 3 of the hint ladder.

Exercise 3: Read the error log

#

A student's last 12 entries in the "why I failed" column: off-by-one (4), didn't recognise pattern (3), integer overflow (2), wrong data structure (1), misread input format (2). What should their next week look like?

Exercise 4: Set up your coach

#

Save the coach instructions in an assistant you use. Solve two problems from your weakest pattern with it, without asking for the solution. Record how many hint rungs you needed, and start your error log.

Show solutionHide solution

(a) Sliding window (variable size). Signal: contiguous subarray, all positive numbers (so the sum grows as the window expands and shrinks as it contracts), n up to 10^5 needs O(n).

(b) Sort plus a heap (or a sweep over start and end times). Signal: intervals and "minimum number of resources at once". Sort by start time and keep a min-heap of end times.

(c) Breadth-first search on a grid. Signal: minimum number of moves with equal-cost steps.

(d) Two pointers. Signal: sorted array and a pair that sums to a target. Move the left or right pointer depending on the sum.

(e) Binary search on the answer. Signal: "minimise the maximum", plus a check that is easy for a given limit (can we split into at most k parts with each part at most X?) and monotonic in X.

Exercise 2

Show solutionHide solution
  • Rung 1: Sliding window.
  • Rung 2: Keep a window with no repeated characters. When the new character is already in the window, move the left edge until it is not. A set or a map of last positions tells you what is in the window.
  • Rung 3: For each right index: while s[right] is in the window's set, remove s[left] and advance left; add s[right]; update the best length with right - left + 1. Each character enters and leaves the window at most once, so it is O(n).

Notice that each rung gives a little more, and that rung 3 is still not code.

Exercise 3

Show solutionHide solution

Mechanical errors (off-by-one 4, overflow 2, misread input 2) account for 8 of 12. Recognition (3) and data-structure choice (1) for 4. So the biggest gain is careful execution, not new patterns.

Next week:

  • Before coding each problem, write the loop bounds and what each pointer means; trace the smallest example by hand after coding (off-by-one).
  • Add an overflow check to the edge-case checklist; use 64-bit types by default when values can be large.
  • Read the input format twice and write the input-reading code first.
  • Keep one pattern-recognition drill a day: read five problem statements and name the pattern without solving.

After a week, compare the new error-log entries.

Exercise 4

Show solutionHide solution

A good outcome looks like this in your notes:

Code
Pattern: monotonic stack (weakest)Problem 1: next greater element. Rungs used: 1 (pattern name). Solved in 28 min.Problem 2: largest rectangle in histogram. Rungs used: 1, 2, 3. Solved afteroutline; needed help with what to do when popping.Error log: "Didn't know what to compute when an element is popped: width usesthe new top of the stack as the left boundary."

If the assistant gave you full code without being asked, tighten the instructions ("Never write code for me") and remind it at the start of each session.

Where to go next

#

Keep reading

More in Career →
  • Guide · Career

    Interview Preparation and Mock Interviews with AI

  • Guide · Career

    Improve Your Resume and Profile with AI, Honestly

  • Guide · Career

    A LinkedIn Profile That Gets Recruiter Messages