Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Feature #3: Check if Meeting is Possible

Sumit Rawal answered on May 24, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Feature #1: Find Meeting Rooms
  • Feature #5: Find Common Meeting Times

  • Feature #3: Check if Meeting is Possible

    0

    Here is how we will implement this feature:

    BST class: First, we will implement a simple BST class with a constructor, an insert function, and an addNode function.

    constructor: The default constructor initializes the root of the node as null. Later on, this root will be of type Node.

    insert() function: This function takes in the start and end timing of meetings and creates a new node. If the root is null, then the new node will become the root. Otherwise, the recursive helper function addNode will be called. The return type of this function is Boolean, as we will use it to determine if the node was added successfully.

    addNode() function: This recursive helper function has two inputs: currentNode, which is initially the root node, and the newNode to be added. We will check if the newNode starts before the currentNode ends; this shows that there is no conflict up to this point. This means we will have to call the recursive function again to check for a conflict in the right child of the currentNode. If the previous check does not pass, we will check if the newNode starts after the currentNode and similarly call the recursive function for the left subtree if the check passes. If both of these conditions fail, this means that the new meeting overlaps with an existing meeting. Therefore, we will return false.

    checkMeeting() function: We initialize the BST with the user’s scheduled meetings in this function. Then, we will add the new meeting and return the result. 

    Popularity 1/10 Helpfulness 1/10 Language scala
    Source: Grepper
    Tags: scala
    Link to this answer
    Share Copy Link
    Contributed on May 24 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.