JOBSEEKER?

As a part of the route planner, the RouteExists method is used as a quick filter if the destination is reachable, before using more computationally intensive procedures for finding the optimal route.

The roads on the map are rasterized and produce a matrix of boolean values - true if the road is present or false if it is not. The roads in the matrix are connected only if the road is immediately left, right, below or above it.

Finish the RouteExists method so that it returns true if the destination is reachable or false if it is not. The fromRow and fromColumn parameters are the starting row and column in the mapMatrix. The toRow and toColumn are the destination row and column in the mapMatrix. The mapMatrix parameter is the above mentioned matrix produced from the map.

For example, for the given rasterized map, the code below should return true since the destination is reachable:

bool[,] mapMatrix = {
	{true, false, false},
	{true, true, false},
	{false, true, true}
};

RouteExists(0, 0, 2, 2, mapMatrix);
C# 8.0, .NET Framework 4.8  


  •   Example case: System.NotImplementedException at RoutePlanner.RouteExists(Int32 fromRow, Int32 fromColumn, Int32 toRow, Int32 toColumn, Boolean[,] mapMatrix) in RoutePlanner.cs:line 8
  •   Various routes from top-left to bottom-right corner: System.NotImplementedException at RoutePlanner.RouteExists(Int32 fromRow, Int32 fromColumn, Int32 toRow, Int32 toColumn, Boolean[,] mapMatrix) in RoutePlanner.cs:line 8
  •   Various routes, starts, and destinations: System.NotImplementedException at RoutePlanner.RouteExists(Int32 fromRow, Int32 fromColumn, Int32 toRow, Int32 toColumn, Boolean[,] mapMatrix) in RoutePlanner.cs:line 8
  •   Performance test on large map: System.NotImplementedException at RoutePlanner.RouteExists(Int32 fromRow, Int32 fromColumn, Int32 toRow, Int32 toColumn, Boolean[,] mapMatrix) in RoutePlanner.cs:line 8

Tags
C# 2D array Algorithmic thinking Graphs New Public
Hard

30min

Would you like to see our other questions?

We have 1000+ premium hand-crafted questions for 50+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.

Visit our question library
Private Concierge

Send us an email with an explanation of your testing needs and a list of candidates. We will create an appropriate test, invite your candidates, review their results, and send you a detailed report.

Contact Private Concierge

On the TestDome Blog

Screening Applicants: The Good, the Bad and the Ugly

Since we’re all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they’ve been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts disagree with each other. Everybody praises their pet method and criticizes the others. Many of these methods look legitimate, but are based on...

Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers