PROBLEM OF THE DAY: 03/12/2023 | Brothers From Different Roots
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-03122023-brothers-from-different-roots/
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.
PROBLEM OF THE DAY: 03/12/2023
Welcome to the daily solving of our PROBLEM OF THE DAY with Siddharth Hazra. 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 Binary Search Trees but also build up problem-solving skills.
In this problem, we are given two BSTs containing N1 and N2 distinct nodes respectively, and given a value x, your task is to complete the function countPairs(), which returns the count of all pairs of (a, b), where a belongs to one BST and b belongs to another BST, such that a + b = x.
Example :
Input:
BST:
5
/ \
3 7
/ \ / \
2 4 6 8
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/brothers-from-different-root/1
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK