PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Solve shipping capacity and expression insertion

Last updated: Mar 29, 2026

Quick Overview

This combined prompt evaluates algorithmic problem-solving skills: the first problem tests array partitioning and capacity planning under ordering and resource constraints, and the second tests combinatorial expression generation, tokenization, and numeric edge-case handling in digit strings.

  • medium
  • Meta
  • Coding & Algorithms
  • Machine Learning Engineer

Solve shipping capacity and expression insertion

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem A: Minimum shipping capacity You are given an array `weights` where `weights[i]` is the weight of the `i`-th package. Packages must be shipped in order (you cannot reorder). You have `D` days to ship all packages. Each day, you load a contiguous prefix of the remaining packages onto the ship, up to the ship's capacity `C`. The total weight loaded that day cannot exceed `C`. **Task:** Return the minimum integer capacity `C` that allows shipping all packages within `D` days. **Input:** - `weights`: array of positive integers - `D`: positive integer **Output:** - Minimum feasible ship capacity `C` **Example:** - `weights = [1,2,3,4,5,6,7,8,9,10]`, `D = 5` → output `15` **Constraints (typical):** - `1 <= len(weights) <= 1e5` - `1 <= weights[i] <= 1e5` - `1 <= D <= len(weights)` --- ## Problem B: Insert `+`, `-`, or concatenate to hit target You are given a string `s` consisting only of digits (e.g., `"123"`) and an integer `target`. You may insert between any two adjacent digits one of: - `'+'` - `'-'` - nothing (concatenate digits into a multi-digit number) This forms an arithmetic expression evaluated left-to-right with normal integer addition/subtraction. **Task:** Return **all** distinct expressions (as strings) that evaluate to `target`. **Rules / edge cases:** - A number token cannot have leading zeros (e.g., `"05"` is invalid), except the token `"0"` itself. - You must use the digits in `s` in order; you cannot reorder or skip digits. **Input:** - `s`: digit string - `target`: integer **Output:** - List of expression strings that evaluate to `target` (order not important) **Example:** - `s = "123"`, `target = 6` → `["1+2+3"]` - `s = "105"`, `target = 5` → `["10-5"]` (but not `"1+0+5"` if it doesn't match) **Constraints (typical):** - `1 <= len(s) <= 10~12` (small enough to allow backtracking) - Result count may be large; return all that exist

Quick Answer: This combined prompt evaluates algorithmic problem-solving skills: the first problem tests array partitioning and capacity planning under ordering and resource constraints, and the second tests combinatorial expression generation, tokenization, and numeric edge-case handling in digit strings.

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
Dec 15, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
8
0

Problem A: Minimum shipping capacity

You are given an array weights where weights[i] is the weight of the i-th package. Packages must be shipped in order (you cannot reorder). You have D days to ship all packages.

Each day, you load a contiguous prefix of the remaining packages onto the ship, up to the ship's capacity C. The total weight loaded that day cannot exceed C.

Task: Return the minimum integer capacity C that allows shipping all packages within D days.

Input:

  • weights : array of positive integers
  • D : positive integer

Output:

  • Minimum feasible ship capacity C

Example:

  • weights = [1,2,3,4,5,6,7,8,9,10] , D = 5 → output 15

Constraints (typical):

  • 1 <= len(weights) <= 1e5
  • 1 <= weights[i] <= 1e5
  • 1 <= D <= len(weights)

Problem B: Insert +, -, or concatenate to hit target

You are given a string s consisting only of digits (e.g., "123") and an integer target.

You may insert between any two adjacent digits one of:

  • '+'
  • '-'
  • nothing (concatenate digits into a multi-digit number)

This forms an arithmetic expression evaluated left-to-right with normal integer addition/subtraction.

Task: Return all distinct expressions (as strings) that evaluate to target.

Rules / edge cases:

  • A number token cannot have leading zeros (e.g., "05" is invalid), except the token "0" itself.
  • You must use the digits in s in order; you cannot reorder or skip digits.

Input:

  • s : digit string
  • target : integer

Output:

  • List of expression strings that evaluate to target (order not important)

Example:

  • s = "123" , target = 6 → ["1+2+3"]
  • s = "105" , target = 5 → ["10-5"] (but not "1+0+5" if it doesn't match)

Constraints (typical):

  • 1 <= len(s) <= 10~12 (small enough to allow backtracking)
  • Result count may be large; return all that exist

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Machine Learning Engineer•Meta Machine Learning Engineer•Meta Coding & Algorithms•Machine Learning 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.