Skip to content

added c++ code for 845. Longest Mountain in Array#88

Merged
GouravRusiya30 merged 4 commits intocodedecks-in:masterfrom
IliasKhan:master
Oct 12, 2020
Merged

added c++ code for 845. Longest Mountain in Array#88
GouravRusiya30 merged 4 commits intocodedecks-in:masterfrom
IliasKhan:master

Conversation

@IliasKhan
Copy link
Copy Markdown
Contributor

Pull Request Template

Description

Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:B.length >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
(Note that B could be any subarray of A, including the entire array A.)
Given an array A of integers, return the length of the longest mountain. Return 0 if there is no mountain.

CodeExplain:
while treversing the array..we have to just count increasing and decreasing numbers.
and maximize the addition of increasing and decreasing numbers.

Put check marks:

Have you made changes in README file ?

  • Added problem & solution under correct topic.
  • Specified Space & Time complexity.
  • Specified difficulty level, tag & Note(if any).

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • input1: [2,1,4,7,3,2,5]
  • input2: [2,2,2]

Make sure all below guidelines are followed else PR will get Reject:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code so that it is easy to understand
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@GouravRusiya30
Copy link
Copy Markdown
Member

Very nicely documented @IliasKhan

@GouravRusiya30 GouravRusiya30 merged commit d973a9a into codedecks-in:master Oct 12, 2020
sublimemonk added a commit to sublimemonk/LeetCode-Solutions that referenced this pull request Mar 23, 2026
sublimemonk added a commit to sublimemonk/LeetCode-Solutions that referenced this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants