Find Highest Product Segment
Company: Bytedance
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates algorithmic problem-solving with arrays and numerical edge cases, including reasoning about products across contiguous segments and sign/zero handling.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([2,3,-2,4],)
Expected Output: 6
Explanation: Best segment is [2,3].
Input: ([-2,0,-1],)
Expected Output: 0
Explanation: Zero is better than negative products.
Input: ([-2,3,-4],)
Expected Output: 24
Explanation: Two negatives can produce a large positive product.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.