Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6084087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:28:51+00:00 2026-05-23T11:28:51+00:00

In Project Euler’s problem 67 there is a triangle given and it contains 100

  • 0

In Project Euler’s problem 67 there is a triangle given and it contains 100 rows. For e.g.

        5
      9  6
    4   6  8
  0   7  1   5

I.e. 5 + 9 + 6 + 7 = 27.

Now I have to find the maximum total from top to bottom in given 100 rows triangle.

I was thinking about which data structure should I use so that problem will get solved efficiently.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:28:51+00:00Added an answer on May 23, 2026 at 11:28 am

    You want to store this as a directed acyclic graph. The nodes are the entries of your triangular array, and there is an arrow from i to j iff j is one row lower and immediately left or right of i.

    Now you want to find the maximum weight directed path (sum of the vertex weights) in this graph. In general, this problem is NP-complete, however, as templatetypedef points out, there are efficient algorithms for DAGs; here’s one:

    algorithm dag-longest-path is
        input: 
             Directed acyclic graph G
        output: 
             Length of the longest path
    
        length_to = array with |V(G)| elements of type int with default value 0
    
        for each vertex v in topOrder(G) do
            for each edge (v, w) in E(G) do
                if length_to[w] <= length_to[v] + weight(G,(v,w)) then
                    length_to[w] = length_to[v] + weight(G, (v,w))
    
        return max(length_to[v] for v in V(G))
    

    To make this work, you will need to weight the length of the path to be the size of the target node (since all paths include the source, this is fine).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From Project Euler, problem 45: Triangle, pentagonal, and hexagonal numbers are generated by the
In Project Euler, a problem asks me to write a program to find the
Overall Problem: Project Euler 12 - What is the value of the first triangle
I am working on Project Euler Problem 4 , and need to find the
In a Project Euler problem I need to deal with numbers that can have
I have taken Problem #12 from Project Euler as a programming exercise and to
From Project Euler, problem 45 : Triangle, pentagonal, and hexagonal numbers are generated by
I am doing another Project Euler problem and I need to find when the
I am doing yet another Project Euler problem - Problem 38 . I have
I have this code written for a Project Euler problem in c++: int sum

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.