PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Optimize flight costs and find grid path

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithm design and problem-solving skills for array-based cost optimization and grid pathfinding, including selection under ordering constraints, path existence detection and path reconstruction, together with correctness and edge-case reasoning.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Optimize flight costs and find grid path

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

1) Given two integer arrays D and R of equal length n, where D[i] is the cost to depart on day i and R[j] is the cost to return on day j, choose indices i and j with 0 <= i < j < n (return strictly after departure) to minimize the total trip cost C = D[i] + R[j]. Return the minimal cost and the chosen days (i, j). Design an algorithm, explain its time and space complexity, justify correctness, and discuss edge cases (e.g., n < 2, ties). 2) Given an m x n binary grid where 0 indicates a walkable cell and 1 indicates a blocked cell, starting at the top-left cell (0, 0) and ending at the bottom-right cell (m-1,n- 1), output any valid path as a list of coordinates if one exists. You may move only up, down, left, or right within bounds. Describe the algorithm to find such a path, how you reconstruct the path, and analyze time and space complexity.

Quick Answer: This question evaluates algorithm design and problem-solving skills for array-based cost optimization and grid pathfinding, including selection under ordering constraints, path existence detection and path reconstruction, together with correctness and edge-case reasoning.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0
  1. Given two integer arrays D and R of equal length n, where D[i] is the cost to depart on day i and R[j] is the cost to return on day j, choose indices i and j with 0 <= i < j < n (return strictly after departure) to minimize the total trip cost C = D[i] + R[j]. Return the minimal cost and the chosen days (i, j). Design an algorithm, explain its time and space complexity, justify correctness, and discuss edge cases (e.g., n < 2, ties).
  2. Given an m x n binary grid where 0 indicates a walkable cell and 1 indicates a blocked cell, starting at the top-left cell (0,
  3. and ending at the bottom-right cell (m-1,n- 1), output any valid path as a list of coordinates if one exists. You may move only up, down, left, or right within bounds. Describe the algorithm to find such a path, how you reconstruct the path, and analyze time and space complexity.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.