Given an integer array, find the contiguous subarray within the array
which has the largest product.
Example:
Input: [1, 2, -4, 1, 3, -2, 3, -1]
Explanation:
2 * (-4) * 1 * 3 * (-2) * 3 = 48
这是一道非常经典但容易踩坑的 数组 + 动态规划类面试题 。难点不在遍历本身,而在于负数会导致最大值和最小值互相翻转,很多候选人第一反应都会走错方向。在 VO 面试中,面试官往往通过这题考察你对边界情况的敏感度,以及能否在讲解过程中不断修正自己的思路。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供、面试辅助、代面试,帮助大家在拿 offer。
正文完