Frequent Sums #307
Labels
CP
Competitive Programming
good first issue
Good for newcomers
hacktoberfest-accepted
Hacktoberfest accepted issues
Medium
Mr Chaggan Lal has just learned the maximum subarray sum problem. And while thinking about the solution, he came up with a new problem, the maximum frequent subarray sum problem.
In this problem, you will be given an array A of N integers. You have to choose a non-empty subarray with the maximum possible score. The score of a subarray is calculated as
Here, occurrences is the number of occurrences of that subarray in A.
Now Chaggan can't solve this problem as he is aged, so please help him solve it and in return you will get blessings of Chaggan Lal for a Placement😉
Input
Output
Sample Input
2
6
10 8 -20 5 5 5
10
-5 1 7 -1 2 -4 10 0 -11 3
Sample Output
20
15
Explanation
The text was updated successfully, but these errors were encountered: