PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Check carpool trip feasibility

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of sweep-line algorithms, interval/event aggregation, and complexity analysis for capacity-constrained scheduling on a one-dimensional route, including handling simultaneous events and edge cases in event ordering.

  • Medium
  • Meta
  • Coding & Algorithms
  • Data Engineer

Check carpool trip feasibility

Company: Meta

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You are given a list of trips where each trip i is (passengers_i, start_i, end_i) with start_i < end_i on a one-dimensional route. A single vehicle with capacity C moves in the increasing direction only; passengers board at start_i and alight at end_i. Implement can_complete_carpool(trips, C) that returns True iff all trips can be completed without exceeding capacity at any point. Use a sweep-line approach with +passengers at start_i and -passengers at end_i; target time/position complexity O(n log n). Discuss edge cases when multiple events share the same coordinate.

Quick Answer: This question evaluates understanding of sweep-line algorithms, interval/event aggregation, and complexity analysis for capacity-constrained scheduling on a one-dimensional route, including handling simultaneous events and edge cases in event ordering.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Aug 1, 2025, 12:00 AM
Data Engineer
Onsite
Coding & Algorithms
5
0

You are given a list of trips where each trip i is (passengers_i, start_i, end_i) with start_i < end_i on a one-dimensional route. A single vehicle with capacity C moves in the increasing direction only; passengers board at start_i and alight at end_i. Implement can_complete_carpool(trips, C) that returns True iff all trips can be completed without exceeding capacity at any point. Use a sweep-line approach with +passengers at start_i and -passengers at end_i; target time/position complexity O(n log n). Discuss edge cases when multiple events share the same coordinate.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 7,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.