Triangle Max Sum: Download App
Triangle Max Sum: Download App
com
http://www.techgig.com/assessment/question/MjgxNUAjJEAjJDE1ODU2ODBAIyRAIyQyMjA5NTc1QCMkQCMkMTQ0OTU2NjcwNg==/1
5
96
468
0715
Write a code to find the maximum total from top to bottom. Assume triangle can have at most 100000 rows.
Output Specification:
A sum of the max numbers in each line(as string) Or Output Invalid in case of Invalid input/triangle.
Exampleseg1:
Input: 5#9#6#4#6#8#0#7#1#5
Output: 29
eg2:
Input: 5#9#6#4#6#8#0#7#1
Output: Invalid
eg2:
Input: 5#9##4#6#8#0#7#1
Output: Invalid
Instructions:
1) Do not write main function.
2) You can print and debug your code at any step of the code.
3) You need to return the required output from the given function.
4) Do not change the function and parameter names given in editor code.
5) Return type must be the same as mentioned in the problem statement.
6) When you submit your code, 10 test cases of different complexity level are executed in the background and marks
are given based on number of test cases passed.
7) If you do not plan to complete the code in one sitting, then please save your work on a local machine. The code is
saved only when it has been submitted using Submit button.
8 ) Only two submissions are allowed.
See sample problems & answers