top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Max Distance Interviewbit Solution

Problem: Max Distance


Problem Description:

Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j].


Input Format

First and only argument is an integer array A.

Output Format

Return an integer denoting the maximum value of j - i;

Example Input

Input 1:
 A = [3, 5, 4, 2]

Example Output

Output 1:
 2

Example Explanation

Explanation 1:
 Maximum value occurs for pair (3, 4).

Solution:


Comments


bottom of page