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.

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:
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)
+, -, or concatenate to hit targetYou 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:
'+'
'-'
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:
"05"
is invalid), except the token
"0"
itself.
s
in order; you cannot reorder or skip digits.
Input:
s
: digit string
target
: integer
Output:
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)