MEDIUMasked at 1 company

Best Sightseeing Pair

A medium-tier problem at 63% community acceptance, tagged with Array, Dynamic Programming. Reported in interviews at Wayfair and 0 others.

Founder's read

Best Sightseeing Pair is a medium-difficulty problem that Wayfair has asked in their online assessments. You're given an array of integers representing sightseeing spot scores, and you need to find the maximum value of scores[i] + scores[j] + (i - j) where i > j. It sounds straightforward until you realize the brute force O(n²) approach times out on large inputs. This is where the DP insight kicks in. If you hit this problem live and freeze on the optimization, StealthCoder solves it invisibly during your assessment.

Companies asking
1
Difficulty
MEDIUM
Acceptance
63%

Companies that ask "Best Sightseeing Pair"

If this hits your live OA

Best Sightseeing Pair 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 an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The trap is trying every pair. Instead, reframe it: for each position j, you want to find the best i that came before it. You can precompute the maximum value of scores[i] - i for all positions up to j, then at each j, compute scores[j] + j plus that precomputed max. This collapses O(n²) to O(n) with a single pass and constant space. The DP trick isn't about a table; it's about realizing you only need to track one running maximum as you iterate. The acceptance rate sits around 63%, so roughly one in three candidates either miss the optimization or implement it wrong under time pressure. StealthCoder is your safety net if the pattern doesn't click during the real assessment.

Pattern tags

The honest play

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

Best Sightseeing Pair 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 an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Best Sightseeing Pair interview FAQ

Is this problem still asked at Wayfair?+

Yes. Wayfair is the only company in reports asking this problem. It appears in their online assessments and is a legitimate filter for optimization chops. The 63% acceptance rate suggests it's fair but not trivial.

What's the core trick?+

Stop thinking 'find all pairs.' Instead, iterate through each j and track the maximum value of (scores[i] - i) seen so far for all i < j. Then the answer at j is scores[j] + j plus that max. One pass, O(n) time, O(1) space.

Why does brute force fail?+

Checking every (i, j) pair is O(n²). On arrays with 10,000 to 100,000 elements, you'll hit time limits. The DP rephrase lets you compute the answer in linear time without nested loops.

How does this relate to Array and Dynamic Programming topics?+

It's an Array problem because you iterate and access elements. It's DP because you optimize by storing and reusing subproblem results (the running max) instead of recalculating them. It teaches the pattern of 'precompute what you'll need as you go.'

What's the most common mistake candidates make?+

Implementing the brute force correctly but timing out, or converting to DP but using extra space (like an array to store all scores[i] - i values). The elegant version uses just one variable to track the rolling max.

Want the actual problem statement? View "Best Sightseeing Pair" 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.