Climbing Stairs1. Introduction to Dynamic Programming Dynamic Programming (DP) is a problem-solving technique that involves breaking a complex problem into simpler overlapping subproblems and solving each subproblem only once. In other words, DP trades redundant co...Mar 20, 2025·84 min read
Flood Fill - BFSAn image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. You should perform a flood fill on the image starting from the pixel image[sr][sc]....Jun 30, 2024·4 min read
Find All Paths From Source to Target - GraphProblem Statement Given a directed acyclic graph (DAG), find all paths from the source node (node 0) to the target node (the last node). The graph is represented as an adjacency list where graph[i] is a list of all nodes i can directly reach. Example...Jun 29, 2024·3 min read
Find All Paths in a MazeYou are given a 2D grid representing a maze where: 'S' represents the starting point, 'E' represents the ending point, '0' represents open paths, and '1' represents walls. You need to find all possible paths from 'S' to 'E' using backtracking. ...Jun 29, 2024·4 min read
Graph : Depth-First Search (DFS)Explain the Problem Implement the Depth-First Search (DFS) algorithm for graph traversal. Given a graph and a starting vertex, traverse the graph in depth-first order and print the vertices in the order they are visited. Example: Input: Graph: 0: [1...Jun 27, 2024·5 min read
Graph - Breadth-First Search (BFS)Explain the Problem Implement the Breadth-First Search (BFS) algorithm for graph traversal. Given a graph and a starting vertex, traverse the graph in breadth-first order and print the vertices in the order they are visited. Example: Input: Graph: 0...Jun 27, 2024·4 min read
N-Queens IIThe n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle. Example 1: Input: n = 4 Output: 2 Explanatio...Jun 27, 2024·3 min read