Skip to content

Hi everyone, I would like to add one question which would be a gainer to the bar of practise in array. #189

Open
@harshit078

Description

@harshit078

The Question is - Given an array of integers, print a sum triangle from it such that the first level has all array elements. From then, at each level number of elements is one less than the previous level and elements at the level is be the Sum of consecutive two elements in the previous level.

Input : A = {1, 2, 3, 4, 5}
Output : [48]
[20, 28]
[8, 12, 16]
[3, 5, 7, 9]
[1, 2, 3, 4, 5]

Explanation :
Here, [48]
[20, 28] -->(20 + 28 = 48)
[8, 12, 16] -->(8 + 12 = 20, 12 + 16 = 28)
[3, 5, 7, 9] -->(3 + 5 = 8, 5 + 7 = 12, 7 + 9 = 16)
[1, 2, 3, 4, 5] -->(1 + 2 = 3, 2 + 3 = 5, 3 + 4 = 7, 4 + 5 = 9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions