Question bank › Binary Search Tree
Dsa Binary Search Tree Hard

Count Unique Paths in BST

Write a program that reads a Binary Search Tree (BST) structure from input and computes the number of unique paths from the root to any leaf node. Each path is defined by the sequence of node values encountered starting at the root and ending at a leaf, without repetition of values. The input consists of a list of edges given as pairs of integers where each integer represents a node's value. The output should be the total number of unique paths. Example Input: 10 5 10 15 5 2 5 7 15 12 15 20 Example Output: 5

Key concepts

binary_search_treedynamic_programmingpathfinding

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.