Guys Plz Help Me Out... Mrityunjay got an assignment from his school that he has to collect money from each house for next day’s event. The city is built just like a 2-D array and each house owner kept certain amount for Mrityunjay (for ex. The house owner at (i, j) co-ordinate kept A[i,j] for Mrityunjay). Mrityunjay is in a hurry and he wants to reach home as soon as possible otherwise he will miss the match between India and Bangladesh. Also he can only move to any adjacent house from his location, and he cannot move diagonally. So please find a way so that he will collect maximum am
maximum amount from everyone if he will reach home earliest. Input Specification input1: first input will tell you the size of array input2: string as shown in the example and you have to parse it to build your 2-D array. Output Specification output1: you need to set maximum amount collected to this global variable (type int)
Example: Consider input1 = 4 and it means school is at (0, 0) and his house at (4,4). In between the houses are like input2 = "(1,7,5,2),(5,12,3,6),(100,9,23,16),(16,4,5,9)" To collect maximum amount Mrityunjay should take this path {1,5,100,9,23,16,9} so total amount collected, output1 = 1+5+100+9+23+16+9 = 163
TOTAL EXAMPLE IS GIVEN ABOVE
Is it the case that Mrityunjay can't go to the same house twice? Is there a limit to the number of houses he can visit before going home? Are we talking Dijkstra's algorithm or some other traversal type? In the meantime, maybe approach the problem like this: -Take in the second input and build the 2-D array from the string. You'll need to parse this string using a stack or similar structure. -Create variables to hold the start and end positions. -Set up a function/method that iteratively checks the current position, neighbors, and distance to the end square. This will depend on what your algorithm is. If you can give us some more information/constraints on the problem, that would be great!
Join our real-time social learning platform and learn together with your friends!