Binary Tree Path Sum - Maximum Sum between any nodes

Problem A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum of a path is the sum of the node’s values in the path. Given the root of a binary tree, return the maximum path sum of any non-empty path. ...

Knight's Tour Problem

Problem The knight is placed on the first block of an empty board and, moving according to the rules of chess, must visit each square exactly once. Knight starts from chess position [0,0] generate the knight’s path. What The problem states that, given a N*M chessboard, a Knight’s Tour is defined as the sequence of moves of a Knight, such that the Knight visits every square only once. ...

Unique Paths in Grid - Count all paths moving right or down or diagonally

Problem There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right or diagonally at any point in time. Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner. ...

Unique Paths in Grid 2-2 - Get all paths moving right or down with obstacles

Problem You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m-1][n-1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any square that is an obstacle. ...

Unique Paths in Grid 2-3 - Get all paths moving in 4 directions with obstacles

Problem You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m-1][n-1]). The robot can only move in any four directions(up, down, right, left) at any point in time. An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any square that is an obstacle. ...

Unique Paths in Grid 1 - Count all paths moving right or down

Problem There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner. ...

N-Queens Problem

Problem The 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 all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solution contains a distinct board configuration of the n-queens’ placement, where 'Q' and '.' both indicate a queen and an empty space, respectively. ...

Unique Paths in Grid 1-2 - Get all paths moving right or down

Problem There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return all possible unique paths that the robot can take to reach the bottom-right corner. ...

Path Sum 2 - find all root to leaf paths

Problem Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. Examples Example 1: graph TD; A[5] --> B[4] & C[8] B --> D[11] & E[null] C --> F[13] & G[4] D --> H[7] & I[2] G --> L[5] & M[1] style A fill:#f9f style B fill:#f9f style C fill:#f9f style D fill:#f9f style I fill:#f9f style G fill:#f9f style L fill:#f9f ...

Unique Paths in Grid 2 - Count all paths moving right or down with obstacles

Problem You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m-1][n-1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any square that is an obstacle. ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy