MEDIUMasked at 1 company

Find Indices With Index and Value Difference II

A medium-tier problem at 32% community acceptance, tagged with Array, Two Pointers. Reported in interviews at Paytm and 0 others.

Founder's read

Find Indices With Index and Value Difference II is a medium-difficulty array problem that's been asked at Paytm. It sits at a 31% acceptance rate, which means most candidates who see this live either miss the constraint or implement a brute force that times out. The trick isn't obvious until you realize the problem is asking you to maintain a sliding window of valid indices while tracking values you've already seen. If you blank on the pattern during your assessment, StealthCoder surfaces a working solution in seconds without the proctor seeing a thing.

Companies asking
1
Difficulty
MEDIUM
Acceptance
32%

Companies that ask "Find Indices With Index and Value Difference II"

If this hits your live OA

Find Indices With Index and Value Difference II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The problem forces you to think beyond nested loops. Brute force is O(n^2) and will fail on larger inputs. The real pattern: use a two-pointer or sliding-window approach to maintain a valid range of indices, then query whether a value within that range matches your difference constraint. Most candidates initially try a hash map of all values, missing that the index difference creates a moving window. The classic pitfall is not shrinking the window when it grows too wide. Two Pointers becomes your weapon here. StealthCoder is the hedge if you hit this during your OA and the window logic doesn't click immediately.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Find Indices With Index and Value Difference II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Indices With Index and Value Difference II interview FAQ

Is this really a medium problem or is it inflated?+

At 31% acceptance, it's genuinely medium-to-hard in practice. The window constraint isn't trivial to spot, and many candidates overthink it or implement a solution that passes small test cases but times out. The problem punishes brute force.

Do I need dynamic programming here?+

No. This is pure Array and Two Pointers. DP is a red herring. The challenge is maintaining the index difference constraint while checking value differences, which a sliding window handles cleanly.

Is the two-pointer approach always optimal?+

For this problem's constraints, yes. Two Pointers keeps you at O(n) or O(n log n) depending on how you handle lookups within the window. Hash maps or sets paired with a sliding window are the standard pattern.

Will this problem appear in real interviews at other companies?+

Paytm is listed as the company here, but index-and-value constraint problems are common in array interview rounds. If you've seen one, you'll recognize the pattern in others. This is a strong drill if you have an upcoming OA.

What's the most common wrong approach?+

Nested loops comparing every pair of indices. It passes examples but times out on large inputs. The second mistake is forgetting to shrink the window when the index difference exceeds the limit, leading to incorrect results.

Want the actual problem statement? View "Find Indices With Index and Value Difference II" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.