We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #18: Maximum path sum I

Project Euler #18: Maximum path sum I

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 18 from projecteuler.net

By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is . The path is denoted by numbers in bold.




That is, .

Find the maximum total from top to bottom of the triangle given in input.

Input Format

First line contains , the number of testcases. For each testcase:
First line contains , the number of rows in the triangle.
For next lines, 'th line contains numbers.

Constraints

Output Format

For each testcase, print the required answer in a newline.

Sample Input

1
4
3
7 4
2 4 6
8 5 9 3

Sample Output

23

Explanation

As shown in statement.

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

8055

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature