Answer: EXTRAMARKS Hiring | On-Campus OA (2025) | Indices With Index and Value Differenc

Answer · Posted Jun 2026

Approach Maintain: Minimum value index seen so far. Maximum value index seen so far. For each position j starting from indexDifference: Update minimum and maximum indices from the valid left window. Check whether current element forms a valid pair with: smallest value seen largest value seen Return immediately if conditions are satisfied. This avoids checking all pairs. Java Code class Solution { public int[] findIndices(int[] nums, int indexDiff, int valueDiff) { int minIdx = 0; int maxIdx = 0; for ...

The full answer & interview discussion are available to premium members.

Log in Create a free account