# Find the Largest Smaller BST Key | Aced

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3059/find-largest-smaller-bst-key
Source observed: 2026-11-05T00:28:07.160Z
Last checked: 2026-11-05T00:28:07.16+00:00
Indexed: 2026-11-06T04:55:50.569+00:00

---

# Find the Largest Smaller BST Key

**Difficulty:** Hard  
**Interview category:** Data Structures & Algorithms  
**Question tags:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms), [Coding](https://www.aced.io/questions?type=coding)

We use this coding question to help candidates practice technical interviews.

## Question

Given the root of a [Binary Search Tree (BST)](http://en.wikipedia.org/wiki/Binary_search_tree) and a number `num`, implement an efficient function `findLargestSmallerKey` that finds the largest key in the tree that is smaller than `num`. If no such number exists, return `-1`. Assume that all keys in the tree are nonnegative.

### Example

For `num = 17` and the binary search tree shown below, the function should return `14`, because `14` is the largest key in the tree that is still smaller than `17`.

![BST example diagram](https://exponent-content.s3.amazonaws.com/img_02_d3b6bf500a.png)

Try the problem in our code editor. The editor includes **Question**, **Solution**, and **Community** tabs, along with optional **Hint 1**, **Hint 2**, and **Challenge 1** sections. The source page also links to a [BST visualizer](https://www.cs.usfca.edu/~galles/visualization/BST.html).

## Access and execution

Detailed company statistics are available through [Upgrade](https://www.aced.io/upgrade?src=questions). You must [sign up to run code](https://www.aced.io/signup?src=lesson). The code workspace provides an editor, output and test-results panels, and a console.

## Related questions

- [Find the k-th smallest and k-th largest element in a binary search tree (BST).](https://www.aced.io/questions/1162/k-th-smallest-largest-in-bst)
- [Find the Smallest Missing Integer](https://www.aced.io/questions/3060/find-smallest-missing-integer)
- [Find the K'th smallest element in an array.](https://www.aced.io/questions/1137/find-ktth-smallest-element-in-array)

## Other interview-preparation options

We offer courses for Product Management, Forward Deployed Engineering, Engineering Management, Software Engineering, System Design, Data Science, Machine Learning, Data Engineering, AI Engineering, Investment Banking, Generative AI, Security Engineering, TPM, Solutions Architecture, UX / Product Design, and BizOps & Strategy. Our broader platform also includes interview questions, practice, experiences, coaching, resume review, salary negotiation, job referrals, resources, and business and university programs.

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3059%2Ffind-largest-smaller-bst-key&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3059%2Ffind-largest-smaller-bst-key). Opening a form does not execute a tool.