Skip to content

thuthancs/dsa-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Coding Interview - Data Structures & Algorithms Patterns

This repo consists of my own categorization of coding interview questions. I collected these questions from multiple sources, primarily LeetCode and books such as Elements of Programming Interviews, Cracking the Coding Interview, and Beyond Cracking the Coding Interview. I like to group the questions under a prominent theme and break them down further into data structures and common techniques.

I organize the questions in order, meaning you need to solve them in the order presented, because subsequent questions are built upon the answers to those that come before. For some patterns that utilize the same data structure, such as trees, I also intentionally organize them in order (e.g., you need to know how to traverse a tree before learning how to search for a specific value in the tree). This approach helps me reinforce my understanding and notice repeated mistakes I make under the same theme.

📘 Table of Contents

Reversal Pattern

Reversal pattern often asks you to change the order of items or swap them in different data structures.

Two Pointers

String

Common pitfalls I made so you don't have to:

  • Forgot to convert a string into a list before performing the swap. Because a string is immutable, we cannot modify it directly.
  • Forgot to use a while loop for the swapping logic, but used an if statement, so the swapping only occurs once.
  • Once in a while, did not handle the index and the bounds of the index well, so got the error of list index out of range.

Linked List

Common pitfalls I made so you don't have to:

  • The trickiest part of reversing a linked list is to keep track of the reassignment of the head/left nodes and right/end nodes. The best solution I found for this problem is to visualise or draw every step for the first few problems you do, instead of just half-dry-running the example. You must internalize the reassignment mechanism before you can proceed to more complex problems.
  • Carefully read the problem to see whether it asks you to swap the values only or to change the pointers/references of the nodes.

Tree Traversal Pattern

Breadth-first Search

Depth-first Search

Search in Trees Pattern

Recursion

Backtracking

Dynamic Programming

Find Optimal Solution

Enumeration

The process of generating or listing all possible solutions to an optimization problem that a DP algorithm solves, rather than just finding the optimal one.

My Favourite List

This list consists of my favourite problems, problems that made me say "Wow, I've never thought of that!" when I looked at the solution and those that have some practical applications

About

A pattern-based collection of data structures and algorithms coding interview questions (with answers and visualizations)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages