Question: Your one - time cod Codility Identity Verificatic Sign larr C : ' app.codility.com / c / run / PAD 8 SE - GCR /

Your one-time cod
Codility
Identity Verificatic
Sign
larr C :'
app.codility.com/c/run/PAD8SE-GCR/
Google
udemy
C.
1
Task 3
Programming Language
Select language
Java 8
English
Files
2
3
You are given an array A consisting of N positive integers. Consider subarrays of A, with at least two elements, whose first and last elements have the same value. Your task is to find the largest possible sum of such a subarray.
For example, for array A=[1,3,6,1,6,6,9,9], the following subarrays meet the requirements:
1,3,6,1 : first and last elements are equal to 1 ; the sum of the subarray is 11.
6,1,6 : first and last elements are equal to 6; the sum of the subarray is 13.
6,1,6,6 : first and last elements are equal to 6 ; the sum of the subarray is 19.
6,6 : first and last elements are equal to 6 ; the sum of the subarray is 12.
9,9 : first and last elements are equal to 9 ; the sum of the subarray is 18.
Allchancies saved
Type here to search
 Your one-time cod Codility Identity Verificatic Sign larr C :' app.codility.com/c/run/PAD8SE-GCR/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!