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. HourRank 25
  3. The Strange Function

The Strange Function

Problem
Submissions
Leaderboard
Discussions
Editorial

One of the most important skills a programmer needs to learn early on is the ability to pose a problem in an abstract way. This skill is important not just for researchers but also in applied fields like software engineering and web development.

You are able to solve most of a problem, except for one last subproblem, which you have posed in an abstract way as follows: Given an array consisting of integers , define

For example, for an input array [ 10, -5, 5, 20 ], a subsegment would be computed as follows:

image

What is , i.e., the maximum value of among all subsegments ?

Complete the function maximumValue which takes an integer array as input and returns the maximum value of among all subsegments .

Note that:

Input Format

The first line contains a single integer

The second line contains space-separated integers

Constraints


Output Format

Print a single integer denoting the answer

Sample Input 0

4
10 -5 5 20

Sample Output 0

50

Explanation 0

The maximum value occurs at as shown below.

image

Sample Input 1

5
7 12 24 6 5

Sample Output 1

144

Explanation 1

The maximum value occurs at .

Author

qoo2p5

Difficulty

Hard

Max Score

70

Submitted By

560

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download all test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature