๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Free course ยท Intermediate

Interview DSA Crash Course

๐Ÿ› Way2Fresher Academy โฑ 4 weeks โญ 4.9 ๐Ÿ‘ฅ 7,200 learners ๐ŸŽ“ Certificate

Free 4 modules ยท 15 lessons Start now โ†’

What you will learn

  • State the time and space cost of your own solution in the interview without being asked twice
  • Recognise the ~12 patterns behind the vast majority of fresher interview questions
  • Write working code on paper or a plain editor, with no autocomplete and no run button
  • Talk through your approach before typing, which is what the interviewer is grading
  • Handle a question you have never seen by reducing it to a pattern you know
  • Recover from a blank moment without going silent for two minutes

Course curriculum

4 modules ยท 15 lessons ยท a worked example and a practice task in every lesson

Module 2Arrays, strings and hashing2 of 43 lessons

Week 2 โ€” the highest-frequency patterns in fresher interviews, and the easiest to practise.

  1. Two pointers

    Two positions moving through one sequence, usually from both ends or at different speeds. It turns a nested loop into a single pass.

    The lesson

    Two pointers is one loop with two moving positions instead of two nested loops. Starting at both ends is for a sorted array and a target sum: if the sum is too small, move the left pointer up; too big, move the right one down. Running one behind the other is for removing duplicates in place or reversing part of a sequence.

    The reason it works is that each pointer only moves forward, so the whole thing is one pass โ€” O(n) time and no extra memory. The trick to explaining it is the invariant: "everything to the left of the slow pointer is processed, and the fast one is looking for the next item to keep".

    The mistakes are forgetting the pointers may cross โ€” the loop condition is usually while (left < right) โ€” and trying to use the two-ended version on an unsorted array, where moving a pointer tells you nothing. Sort first if the question allows it, and say that you did.

    Python
    def two_sum_sorted(nums, target):
        left, right = 0, len(nums) - 1
        while left < right:
            s = nums[left] + nums[right]
            if s == target: return [left, right]
            if s < target:  left += 1      # need bigger -> move left up
            else:           right -= 1     # need smaller -> move right down
        return []
    
    # Sorted input required. One pass: O(n) time, O(1) extra space.

    Example Sorted array, find a pair summing to a target: move the left pointer up when the sum is too small and the right pointer down when it is too large โ€” O(n), and it is O(nยฒ) if you look at every pair.

    Practice Solve reverse-a-string-in-place, check-for-palindrome and pair-sum with two pointers, and write the complexity under each.

  2. Hash maps and sets

    A map trades memory for speed: remembering what you have seen makes "have I seen this before" a constant-time question.

    The lesson

    A hash map stores values by key, and a set stores just the keys, both with an average lookup of O(1). That single property turns an O(nยฒ) double loop into one pass in dozens of interview questions: "find two numbers that add to a target", "the first non-repeating character", "is there a duplicate", "group the anagrams".

    The moving parts: adding a key, checking whether a key exists, reading one back, and counting with counts[x] = counts.get(x, 0) + 1. For a duplicate check a set is enough; for counting or grouping you need the map. In JavaScript a Map is safer than an object when the keys are numbers or come from user input.

    The mistake is using a map when the array is sorted and pointers would do with less memory, or using a set when the question asks for the INDEX of the pair โ€” a set tells you the value exists, not where it was. Read what the question wants returned before choosing the structure.

    Python
    def two_sum(nums, target):
        seen = {}                          # value -> index
        for i, n in enumerate(nums):
            if target - n in seen:
                return [seen[target - n], i]
            seen[n] = i
        return []
    
    # "Is there a duplicate?" needs only a set:
    def has_duplicate(nums):
        return len(set(nums)) != len(nums)
    
    # A set tells you a value EXISTS; a map tells you WHERE.

    Example Counting the frequency of each character in a string in one pass with a map is the same building block used by anagrams, duplicates and most "find the first non-repeating" questions.

    Practice Solve three frequency problems and one "first non-repeating character" problem, each in a single pass.

  3. Sliding window

    A moving window over a sequence is the standard answer to "longest/shortest subarray with some property" โ€” including at non-coding companies that ask only this.

    The lesson

    A sliding window is a range that grows on the right and shrinks on the left while you keep a running answer. "Longest substring without repeating characters" and "smallest subarray with sum at least k" are the same technique: extend until a rule breaks, then move the left edge in until it holds again.

    The window needs a small piece of state โ€” a set of characters, a sum, a count map โ€” and the loop looks the same each time: add the new item, fix the violation by moving left, update the best answer. Written that way it is O(n) with two pointers that never move backwards.

    The mistakes are updating the best answer after shrinking instead of before, and forgetting to remove the item you left behind when the window moves โ€” which produces an answer that is too long and looks almost right in a test. Trace one small example by hand before you run it.

    Python
    def longest_unique(s):
        seen, left, best = set(), 0, 0
        for right, ch in enumerate(s):
            while ch in seen:              # shrink until the rule holds again
                seen.remove(s[left])
                left += 1
            seen.add(ch)
            best = max(best, right - left + 1)
        return best
    
    # O(n): each index is added and removed at most once.

    Example Longest substring without repeating characters: grow the window on the right, shrink from the left while a duplicate exists, remember the largest size. One pass, O(n).

    Practice Implement the longest-substring window and a fixed-size maximum-sum window, and compare both against a brute-force version.

Show all modules on one page

About Interview DSA Crash Course

Solve the interview problems that are actually asked of freshers โ€” out loud, under time, on paper โ€” in four weeks.

Final-year students and graduates with a first round of coding interviews ahead, who can already write a loop and freeze when the timer starts.

What you will be able to do at the end

  • State the time and space cost of your own solution in the interview without being asked twice
  • Recognise the ~12 patterns behind the vast majority of fresher interview questions
  • Write working code on paper or a plain editor, with no autocomplete and no run button
  • Talk through your approach before typing, which is what the interviewer is grading
  • Handle a question you have never seen by reducing it to a pattern you know
  • Recover from a blank moment without going silent for two minutes

How the course is structured

3 modules and 11 lessons, arranged so each one ends with something you have built. Every lesson carries a worked example and a practice task โ€” the practice is the course, the reading is only the setup. Plan for 4 weeks ยท about 8 hours a week.

The full syllabus โ€” every lesson, its example and its practice task โ€” is in the Course curriculum below. Nothing is locked and nothing needs an account.

Your weekly routine

  • Two problems a day, solved on paper first and typed afterwards.
  • One narrated mock interview a week โ€” out loud, timed, no pausing to look anything up.
  • Write the complexity of every solution before typing it, even when you are sure.

What you will have built by the end

  • A pattern notebook: every problem you solve, its pattern and its complexity in one line
  • Four recorded practice interviews narrated out loud
  • A full mock interview from the Career Portal's AI mock-interview tool, with its feedback written down

Where this leads for a fresher

  • Fresher software engineer at a product company
  • Trainee / graduate engineer at a services company
  • Second-round technical interviews you have already qualified for
  • Campus and off-campus hiring drives

Titles vary between companies; the evidence does not. A deployed project, a set of queries you can explain, or a case study with real testing behind it is what a fresher interview has to work with.

Frequently asked questions

How many problems should I solve before interviewing?

Around 60โ€“80 real ones, each narrated out loud, covers the patterns fresher interviews actually use. Numbers in the hundreds without narration is the common trap: you recognise but cannot produce.

I know coding but I freeze in interviews. Is that fixable?

Yes, and it is the most fixable part. Narrating every practice problem out loud, including one full mock a week, is the training โ€” not more reading. Take the free Career Pulse check: communication is one of the areas it scores, and it will show you how much of your gap is interview skill rather than knowledge.

Is this course free?

The lessons, examples and practice tasks are free, and the AI mock-interview tool on the Career Portal is free to use.

Do I need data structures from my college syllabus?

No. Arrays, strings, maps, sets, trees and recursion cover the overwhelming majority of fresher questions. This course teaches exactly those and skips the theory you will not be asked.

Not sure which of these you need first? The free Career Pulse check scores your skills, communication and goal clarity in about three minutes and tells you which gap to close first. Take the free check.