Quick Overview

Choose departure and return days that minimize a round-trip cost while requiring departure before return. Derive a linear scan that retains the best earlier departure and implements exact ties by earliest departure index and then latest return index.

Choose the Cheapest Round Trip

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Choose departure and return days that minimize a round-trip cost while requiring departure before return. Derive a linear scan that retains the best earlier departure and implements exact ties by earliest departure index and then latest return index.

Loading…