Maximum Final Value (Also for AS Intern)

Problem Overview

  • Given an integer array, find the maximum achievable value of the last element after allowed rearrangement and reductions.
  • Constraints: first element must be 1; for i>0, arr[i] − arr[i−1] ≤ 1; elements may be reduced to ≥1 and reordered.
  • Input: int arr[] with 1≤n≤1e5 and 1≤arr[i]≤1e9; Output: int for the maximum final element.
  • Context: onboarding challenge modeling stepwise normalization of array values.
  • From Amazon interviews; a coding interview problem and common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: