Question: Write a java function to solve this problem Takes an array of non-negative integers and returns the largest score for a pair of values. The

Write a java function to solve this problem

Write a java function to solve this problem Takes an array of

Takes an array of non-negative integers and returns the largest score for a pair of values. The value for a pair is their numerical value plus the distance between them. For example, a pair of 5s next to each other is worth 6, but a pair of fives separated by another value is worth 7. A value which occurs only once is considered to pair with itself; it is worth its numerical value. The method should return 0 if the array is empty. largestPair([1,1])+2 largestPair([1, 2, 1)) 3 largestPair([1, 1, 2, 3, 4, 2])5 Go ...Save, Compile, Run (ctrl-enter) int largestPair(int) nums) { return 0; Expected Run largestPair([1,1]) + 2 0 largestPair([1, 2, 1]) + 3 0 X largestPair([1, 1, 2, 3, 4, 2]) 5 0 X largestPair([1])1 0 X largestPair([0])0 0 OK largestPair([0, 0])1 0 X largestPair([2, 2]) + 3 0 largestPair([50, 50]) 51 0 X largestPair([1, 50, 2, 3, 4, 5, 1]) 50 X largestPair([]) 0 0 OK largestPair([1, 4, 2, 7,5, 3, 6])7 0 X largestPair([3, 5, 1, 0, 4, 4, 2, 2, 1)) - 70 X largestPair([1, 2, 2, 1]) - 4 0 largestPair([1, 1, 1, 1]) 4 0 X largest Pair(2, 2, 2, 2]) 5 0 X largestPair([0, 1, 2, 2, 1, 1]) - 5 0 X other tests X 0 *1**[*]******* Your progress graph for this problem Go

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!