Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Cricket Rating problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Cricket Rating problem solution, India is a cricket-crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app. This app analyses the performance of a cricketer. If a cricketer under-performs, then a negative rating is awarded. If performance is good, then a positive rating is awarded to the cricketer.
 
Chang wants to analyze the performance of a cricketer over a period of N matches. Chang wants to find the consistency of a cricketer. So he wants to find out the maximum consistent sum of cricket rating of a batsman or a bowler only if his overall rating is positive over that period. Help change in doing so.
 
 
HackerEarth Cricket Rating problem solution

 

 

HackerEarth Cricket Rating problem solution.

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int prefunction(int a[],int length){
int max1 = 0,max2 = 0;
for(int i = 0;i<length;i++){
max2 = max2 + a[i];
if(max2 < 0)
max2 = 0;
if(max1 < max2)
max1 = max2;
}
return max1;
}
int main()
{
int n;
cin >> n;
int a[n+1];
for(int i = 0;i<n;i++)
cin >> a[i];
int result = prefunction(a,n);
cout << result << endl;
return 0;
}
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes