Search
⌘K

Leetcode 257. Binary Tree Paths

Return all root-to-leaf paths of a binary tree as strings like "1->2->5"; this requires a simple DFS/backtracking traversal to build each path from root to leaf.

Asked at:

Bloomberg

Bloomberg

Justworks


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late July, 2025

Justworks

Senior

Mid March, 2025

Bloomberg

Bloomberg

Senior

Given a binary tree with distinct nodes(no two nodes have the same data values). The problem is to print the path from root to a given node x. If node x is not present then print “No Path”. Examples: Input : 1 / \ 2 3 / \ / \ 4 5 6 7 x = 5 Output : 1->2->5

Comments

Your account is free and you can post anonymously if you choose.