Traversal interview questions
Practice 32 questions on traversal. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
32 questions
- AlgorithmsCoding exercise
Binary Tree Equal
EASYImplement a function that returns whether two binary trees have identical structure and node values.
15 minPractice - AlgorithmsCoding exercise
Binary Tree Maximum Depth
EASYImplement a function that returns the maximum depth from root to leaf in a binary tree.
15 minPractice - AlgorithmsCoding exercise
Flip Binary Tree
EASYImplement a function that mirrors a binary tree by swapping the left and right children of every node.
15 minPractice - AlgorithmsCoding exercise
Binary Search Tree Kth Smallest Element
MEDIUMImplement a function that returns the kth smallest value in a binary search tree.
25 minPractice - AlgorithmsCoding exercise
Binary Search Tree Lowest Common Ancestor
MEDIUMImplement a function that finds the lowest common ancestor of two nodes in a binary search tree.
25 minPractice - AlgorithmsCoding exercise
Binary Tree
MEDIUMBuild a binary tree data structure with the essential insert, traverse, and search operations.
25 minPractice - AlgorithmsCoding exercise
Binary Tree Level Order Traversal
MEDIUMImplement a function that returns the values of a binary tree grouped by level from top to bottom.
25 minPractice - AlgorithmsCoding exercise
Binary Tree Subtree
MEDIUMImplement a function that determines whether one binary tree appears as a subtree of another.
25 minPractice - AlgorithmsCoding exercise
Breadth-First Search
MEDIUMImplement breadth-first traversal of a directed graph, visiting nodes level by level from a start vertex.
25 minPractice - JavaScriptCoding exercise
Corresponding Node Across Pages
MEDIUMImplement a function that locates the node in a mirrored DOM tree occupying the same path as a given node.
25 minMetaPractice - AlgorithmsCoding exercise
Count Islands in a Grid
MEDIUMImplement a function that counts the number of distinct islands of connected cells in a 2D binary grid.
25 minAdobePractice - JavaScriptCoding exercise
Deep Map
MEDIUMImplement a function that walks an arbitrarily nested structure and applies a transform to every leaf value.
25 minGooglePractice - AlgorithmsCoding exercise
Depth-First Search
MEDIUMImplement depth-first traversal of a directed graph, exploring each branch fully before backtracking.
25 minPractice - AlgorithmsCoding exercise
Find Word in Grid
MEDIUMImplement a function that checks whether a target word can be traced through adjacent cells in a 2D character grid.
25 minPractice - JavaScriptCoding exercise
getElementsByClassName
MEDIUMImplement a function that returns all DOM elements containing every one of the specified class names.
25 minAmazon · Discord · Dropbox +2Practice - JavaScriptCoding exercise
getElementsByStyle
MEDIUMImplement a function that returns all DOM elements whose computed style matches a given property and value.
25 minAmazon · ZeptoPractice - JavaScriptCoding exercise
getElementsByTagName
MEDIUMImplement a function that walks a DOM tree and returns every descendant element matching a given tag name.
25 minDropbox · Google · NetflixPractice - AlgorithmsCoding exercise
Graph Clone
MEDIUMImplement a function that produces a deep copy of a connected, undirected graph given a reference node.
25 minPractice - JavaScriptCoding exercise
HTML Sanitizer
MEDIUMImplement a simplified HTML sanitizer that strips out unsafe tags and attributes from a given DOM tree.
25 minPractice - JavaScriptCoding exercise
HTML Serializer
MEDIUMImplement a function that serializes a tree-shaped object into a pretty-printed HTML string with indentation.
25 minTikTokPractice - AlgorithmsCoding exercise
Is the Graph a Tree
MEDIUMImplement a function that determines whether a given undirected graph forms a valid tree.
25 minPractice - AlgorithmsCoding exercise
Matrix Spiral Traversal
MEDIUMImplement a function that walks a 2D matrix in clockwise spiral order and returns the visited values.
25 minPractice - AlgorithmsCoding exercise
Ocean Flow
MEDIUMImplement a function that returns every grid cell from which water can flow to both the Pacific and Atlantic oceans.
25 minPractice - JavaScriptCoding exercise
Squash Object
MEDIUMImplement a function that flattens a nested object into a single-level object using dot-delimited keys.
25 minPractice - AlgorithmsCoding exercise
Validate Binary Search Tree
MEDIUMImplement a function that determines whether a binary tree satisfies the binary search tree ordering invariant.
25 minPractice - AlgorithmsCoding exercise
Binary Tree Serialization and Deserialization
HARDImplement functions that convert a binary tree to a string and reconstruct the same tree back from that string.
40 minPremium questionPractice - AlgorithmsCoding exercise
Dijkstra's Algorithm
HARDImplement Dijkstra's algorithm to compute shortest paths from a source vertex in a weighted graph.
40 minPremium questionPractice - JavaScriptCoding exercise
getElementsByTagNameHierarchy
HARDImplement a function that finds all DOM elements matching an ancestor-to-descendant tag-name hierarchy.
40 minDropbox · GooglePractice - JavaScriptCoding exercise
Lowest Hiding Element
HARDImplement a function that finds the deepest common ancestor whose hiding would conceal every target element.
40 minPremium questionPractice - JavaScriptCoding exercise
Table of Contents
HARDImplement a function that walks an HTML document's headings and builds a nested table of contents.
40 minGooglePractice - JavaScriptCoding exercise
Text Between Nodes
HARDImplement a function that gathers the text content lying between two DOM nodes in document order.
40 minPremium questionMetaPractice - AlgorithmsCoding exercise
Topological Sort
HARDImplement a function that returns a topological ordering of nodes in a directed acyclic graph.
40 minPremium questionSnapPractice