Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerEarth Cricket Rating problem solution

YASH PAL, 31 July 2024
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

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes