Question: javascript only: You have been assigned to work with an undersea explorer who is attempting to identify and map undersea trenches. The explorer has provided
javascript only:
You have been assigned to work with an undersea explorer who is attempting to identify and map undersea trenches. The explorer has provided you with several data sets.
Depending on the scan, the provided matrix may be larger or smaller, but it will always be rectangular. Your task is to determine if a given data set contains a trench by comparing each node and their neighbors and determining if there is a pattern that matches the defined properties of a trench.
Neighbors are considered to be nodes that are directly above, below, or to the side. No diagonals!
A trench has the following three properties:
It has a length of three or more nodes that are neighbors.
Each node in the trench must be deeper than -5.
Trenches may not branch into (any form of) a "T" shape. A node with more than two neighbors will result in branching "T" shape.
// Example 1 sonar = [ [-5,-5,-5,-5,-5], [-5,-8,-8,-9,-7], [-5,-5,-5,-5,-8], [-5,-5,-5,-5,-5] ]

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
