MEDIUMasked at 2 companies

Find Beautiful Indices in the Given Array I

A medium-tier problem at 38% community acceptance, tagged with Two Pointers, String, Binary Search. Reported in interviews at Palantir Technologies and 1 others.

Founder's read

Find Beautiful Indices hits medium difficulty with a 38% acceptance rate, which means most candidates miss the optimization on first try. Palantir and Samsara both ask this one. The problem looks deceptively simple: find indices in one array where a pattern exists within a distance threshold in another array. Most people write the brute force, time out, then realize they need to collapse the problem into something cleaner. If this lands in your OA and the naive approach times out, StealthCoder surfaces the optimized pattern in seconds, invisible during screen share.

Companies asking
2
Difficulty
MEDIUM
Acceptance
38%

Companies that ask "Find Beautiful Indices in the Given Array I"

If this hits your live OA

Find Beautiful Indices in the Given Array I 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. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trap is thinking you need nested loops checking every combination. The real pattern uses two pointers or binary search to collapse redundant work. You track valid positions in one array, then for each position in the other, you ask: is there a valid match within the distance constraint. This shifts from quadratic to linear or log-linear depending on your implementation. String matching and rolling hash come up if the problem variant requires substring comparison before you even check distance. The two-pointer approach is the hedge most miss because it requires you to think about the problem in reverse: instead of checking all pairs, you advance one pointer and ask if the other pointer can stay within bounds. That's the moment candidates blank and where StealthCoder becomes critical.

Pattern tags

The honest play

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

Find Beautiful Indices in the Given Array I 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. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Beautiful Indices in the Given Array I interview FAQ

Is this really a medium or does it feel harder?+

The 38% acceptance rate confirms it's punching above typical medium difficulty. The logic isn't complex, but the optimization leap from brute force to two pointers is where most candidates get stuck. If you don't nail the pointer strategy on the first try, you'll time out.

Do Palantir and Samsara still ask pattern-matching distance problems?+

Yes. Both companies have reported this problem. It's a solid screening filter for backend roles where you need to optimize beyond the obvious loop. The problem type (matching with constraints) is stable across hiring cycles.

What's the trick nobody sees coming?+

Once you find valid indices in one array, you don't re-scan. You use binary search or two pointers to jump to the next valid index in constant or log time. Most people write three nested loops and wonder why they time out. The collapse is what separates AC from TLE.

Does string matching come up in the actual problem?+

It depends on the variant. The input topics list string matching and rolling hash, so some versions do require substring matching before distance checks. Verify which variant your OA uses. The core distance logic is the same regardless.

How does this relate to two pointers versus binary search?+

Two pointers works if you can process both arrays in order. Binary search works if you pre-compute valid positions and then query them. Both are optimal. Two pointers is usually easier to code under pressure, which matters during a live OA.

Want the actual problem statement? View "Find Beautiful Indices in the Given Array I" 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.