Question: You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the
You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the program is important so it is best to use an algorithm in the code which will not timeout



Goldilocks Treasure Islands Problem Submissions Leaderboard Discussions Ain Captain Pi has hidden his treasures among an archipelago of n islands. Instead of drawing a map to his treasure Islands though, he has left a series of clues for himself on several islands, only some of which actually contain any treasure. Each clue contains a number and up to two references to other islands. He has a secret number, s, which serves as the key to finding the treasures in the islands. Starting with the first clue, whenever the sequence of numbers on a chain of clues sum to a multiple of s, then that island contains treasure. Contest ends in 7 days Submissions: 0 Max Score: 25 Difficulty: Medium Rate This Challenge More 3 2 For example the diagram shows where the treasures would be located if s = 7 and the clues made references as shown. The first clue on island A has the number 2 and references islands B and Cas follow-up islands. Since the clue on island B has the value 5 and 2+5 is divisible by 7, that means that there is treasure on island B. Goldilocks has figured out Captain Pis scheme, but she is a lazy pirate (and thief) and won't go after all of the treasure. If the number of treasure containing Islands on any path of islands is fewer than I or more than h, she is not interested in it (either not worth it, or too much work) Given the complete set of clues (starting from island #1), the secrets, and the values of and h, find the number of paths that would interest Goldilocks. In this problem, a tree will be constructed from the input for you, but in order for that given code to work, you must first complete the ADT for binary trees that was started, but left incomplete Input Format The first line contains four integers, separated by a space in the format: nslh The next n lines contains 4 integers: jk to indicate that the clue on island has the number and makes reference to Islands numbered j and k. If either jor kis 0, then no reference in that position was made by that clue. . Constraints 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
