Grokking Oracle Coding Interview
Ask Author
Back to course home

0% completed

Minimize Maximum of Array (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given a positive integer array nums, return the minimum possible value of the maximum integer of nums after performing multiple operations.

In one operation, you must:

  • Select any index i such that 1 <= i < n and nums[i] > 0.
  • Increase nums[i - 1] by 1.
  • Decrease nums[i] by 1.

Examples

Example 1:

  • Input: nums = [4, 5, 3, 2, 1, 6]
  • Expected Output: 5
  • Justification: We can perform operations to decrease the last element (6) to 5 and increase the fifth element to 2. Here, the maximum array element is 5.

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible