PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Zillow

Find max min-plus-max over all subarrays

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of array-processing algorithms, efficient computation of range aggregates (min and max), and skills in algorithmic optimization and complexity analysis.

  • medium
  • Zillow
  • Coding & Algorithms
  • Machine Learning Engineer

Find max min-plus-max over all subarrays

Company: Zillow

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given an array `arr` of `n` integers. A **subarray** is a contiguous non-empty segment of the array. For any subarray `arr[l..r]` (0-indexed), define: \[ X(l, r) = \min(arr[l..r]) + \max(arr[l..r]) \] Your task is to compute the maximum possible value of `X(l, r)` over all subarrays of `arr`. ### Input - An integer `n` (the length of the array). - An array `arr` of `n` integers (can be positive, zero, or negative). ### Output - A single integer: the maximum value of `min(subarray) + max(subarray)` over all possible non-empty contiguous subarrays. ### Requirements - Describe an efficient algorithm and its time and space complexity. - Aim for better than \(O(n^2)\) time for large `n` (e.g., `n` up to around `2 * 10^5`).

Quick Answer: This question evaluates a candidate's understanding of array-processing algorithms, efficient computation of range aggregates (min and max), and skills in algorithmic optimization and complexity analysis.

Related Interview Questions

  • Write pseudocode for a ReAct-style loop - Zillow (medium)
  • Implement k-th largest in a number stream - Zillow (medium)
  • Implement placeholder-based pattern matcher - Zillow (medium)
Zillow logo
Zillow
Jul 18, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
3
0

You are given an array arr of n integers.

A subarray is a contiguous non-empty segment of the array. For any subarray arr[l..r] (0-indexed), define:

X(l,r)=min⁡(arr[l..r])+max⁡(arr[l..r])X(l, r) = \min(arr[l..r]) + \max(arr[l..r])X(l,r)=min(arr[l..r])+max(arr[l..r])

Your task is to compute the maximum possible value of X(l, r) over all subarrays of arr.

Input

  • An integer n (the length of the array).
  • An array arr of n integers (can be positive, zero, or negative).

Output

  • A single integer: the maximum value of min(subarray) + max(subarray) over all possible non-empty contiguous subarrays.

Requirements

  • Describe an efficient algorithm and its time and space complexity.
  • Aim for better than O(n2)O(n^2)O(n2) time for large n (e.g., n up to around 2 * 10^5 ).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Zillow•More Machine Learning Engineer•Zillow Machine Learning Engineer•Zillow Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.