Tag: depth first search algorithm
Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path …
The n queens puzzle asks to place n queens on an n×n chessboard so that no two queens are attacking each other. Given a partially filled two-dimensional integer matrix …
Teaching Kids Programming: Videos on Data Structures and Algorithms Given a binary tree root, return the number of unique vertical lines that can be drawn such that every node …
Teaching Kids Programming: Videos on Data Structures and Algorithms Given a binary tree root, repeatedly delete all leaves that have even values. That is, if after deletions, a node …
Teaching Kids Programming: Videos on Data Structures and Algorithms In Python, we have itertools.product that calculates the Cartesian Product of a few list or tuple. For example: from itertools …