0% found this document useful (0 votes)
37 views2 pages

Triangle Max Sum: Download App

The document describes a problem to find the maximum total sum from a triangle of numbers represented as a string, where each subsequent row contains the sum of the maximum numbers from the row above. It provides examples of valid and invalid input strings, and instructions for solving the problem by returning the sum or "Invalid" from a given function without changing the function signature or main method.

Uploaded by

Pavan Prakashh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Triangle Max Sum: Download App

The document describes a problem to find the maximum total sum from a triangle of numbers represented as a string, where each subsequent row contains the sum of the maximum numbers from the row above. It provides examples of valid and invalid input strings, and instructions for solving the problem by returning the sum or "Invalid" from a given function without changing the function signature or main method.

Uploaded by

Pavan Prakashh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

techgig.

com
http://www.techgig.com/assessment/question/MjgxNUAjJEAjJDE1ODU2ODBAIyRAIyQyMjA5NTc1QCMkQCMkMTQ0OTU2NjcwNg==/1

Triangle Max Sum


Download App

Time Remaining 2:23:19


Imagine you have a row of numbers like below(a triangle). By starting at the top of the triangle, find the maximum
number in each line and sum them up. Example below.

5
96
468
0715

Answer I.e. 5 + 9 +8 + 7 = 29.

Write a code to find the maximum total from top to bottom. Assume triangle can have at most 100000 rows.

Input/Output Specifications Input Specification:


A string of n numbers (where 0<=n<=1010)
eg. 5#9#6#4#6#8#0#7#1#5

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

You might also like