4

PROBLEM OF THE DAY: 02/09/2023 | Leaf under budget

 1 year ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-02092023-leaf-under-budget/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PROBLEM OF THE DAY: 02/09/2023

Hi, and welcome to
September 03, 2023 |670 Views
PROBLEM OF THE DAY: 02/09/2023 | Leaf under budget
Problem of the Day, Data Structure and Algorithm, binary-tree
 Save  Share  1 Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Self-balancing BST but will also help you build up problem-solving skills.

In this problem, we are given a binary tree and a budget. Assume you are at the root of the tree(level 1), we need to maximize the count of leaf nodes you can visit in your budget if the cost of visiting a leaf node is equal to the level of that leaf node.

Example :

Input: 
                 10
               /    \
              8      2
            /      /   \
           3      3     6
                   \
                    4
and budget = 8

Output: 2

Explanation:
Cost For visiting Leaf Node 3: 3
Cost For visiting Leaf Node 4: 4
Cost For visiting Leaf Node 6: 3
In budget 8 one can visit Max 2 Leaf Nodes.

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK