Newzera | Online Coding Round | Matrix Challenge

Given a 2d matrix in the form of a string array containing positive integers. Your goal is to determine the largest number that can be found by adding up three elements in the matrix that are in the same path, where same path means starting from one of the elements and when moving either up, down, right, left onto the next element without resuing elements. One caveat though, and that is when you calculate the sum of three digits, you should split the sum into two digits and treat the new digits as a row/coloumn position in the matrix.
So your goal is actually to find the sum of three digits that sums to the largest position in the matrix without going out of bounds.

For example [ "345" , "326" , "221"]
3 4 5
3 2 6
2 2 1

The solution to this problem is to sum 4 + 2 + 6 = 12. Then you take this and split it into 1 and 2 which represents, row 1 and col 2 in the matrix. This is the largest postion you can get in the matrix by adding up 3 elements so your program should return 12.
If you find a single digit sum then treat it as , row 0 and col sum.

Complete the function :
int MatrixChallenge(string[] arr, int n) { }

Examples
-> Input : {"234", "999", "999"}
Output : 22

-> Input : {"11111", "22222"}
Output : 4

Please help me with an approach and solution.

Comments (1)