• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 02, 2024 |580 Views
PROBLEM OF THE DAY : 01/04/2024 | Pairs violating the BST property
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Nitin Kaplas. 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 BST but also build up problem-solving skills.

In this problem, we are given a binary tree with n nodes, find the number of pairs violating the BST property.
BST has the following properties:-

  • Every node is greater than its left child and less than its right child.
  • Every node is greater than the maximum value of in its left subtree and less than the minimum value in its right subtree.
  • The maximum in the left sub-tree must be less than the minimum in the right subtree.

    Give the problem a try before going through the video. All the best!!!
    Problem Link: https://www.geeksforgeeks.org/problems/pairs-violating-bst-property--212515/1