FastPrepFind Contiguous Subarray with Largest Min Plus Max 🐝 -- Not OA but an INTERVIEW Question! 🌷 :)
Problems/Find Contiguous Subarray with Largest Min Plus Max 🐝 -- Not OA but an INTERVIEW Question! 🌷 :)

Find Contiguous Subarray with Largest Min Plus Max 🐝 -- Not OA but an INTERVIEW Question! 🌷 :)

Google logoGoogle● MediumINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Special thanks: 𓆑 🫧A HUGE THANK YOU TO THE INCREDIBLE RACHEL!π“ˆ’ 🧑

Given an array of n positive integers, find a contiguous subarray (containing more than one number) with the largest min + max.

Function

findContiguousSubarrayWithLargestMinPlusMax(nums: int[]) β†’ int

Complete the function findContiguousSubarrayWithLargestMinPlusMax in the editor.

findContiguousSubarrayWithLargestMinPlusMax has the following parameter:

  1. int nums[n]: an array of integers

Returns int: the largest sum of min and max of a contiguous subarray

Note

Solve better than O(n^3)

Examples

Example 1

nums = [4, 6, 2, 8, 10]return = 18

The contiguous subarray with the largest min + max is [8, 10], where the min is 8 and the max is 10. Therefore, the answer is 10 + 8 = 18.

Example 2

nums = [6, 2, 9, 1, 7]return = 11

The contiguous subarray with the largest min + max is [2, 9], where the min is 2 and the max is 9. Therefore, the answer is 2 + 9 = 11.

Constraints

  • 2 <= nums.length <= 10^5
  • 1 <= nums[i] <= 10^9

More Google interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW Β· Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW Β· Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN Β· Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN Β· Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW Β· Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW Β· Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026

Similar questions at other companies

  • Minimum Cost to Merge Values into OnePayPal Β· OAPayPal interview questions
  • Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon Β· OA
  • Minimum Cost of Left and Right PropagationAmazon Β· OA
  • Minimum Rounds to Complete All TasksInfosys Β· OAInfosys interview questions
  • Reschedule Meetings for Maximum Free TimeFivetran Β· OAFivetran interview questions
  • Maximum Easy Tasks After RearrangingIBM Β· OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft Β· OAMicrosoft interview questions
  • Maximum ScoreNVIDIA Β· OANVIDIA interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot Β· OA
  • Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company Β· OAMcKinsey & Company interview questions

Interview reports that mention this question

  • Google OA: What It Tests (2026)

Google interview experiences

  • Google L5 Security Engineer Domain Knowledge Round: 1 Experience
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int findContiguousSubarrayWithLargestMinPlusMax(int[] nums) {
      // write your code here
    }

}
Checking account…