У нас вы можете посмотреть бесплатно #LEETCODE или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
This program finds the maximum product subarray in a given integer array. It uses two running products: Prefix product → multiplies numbers from left to right. Suffix product → multiplies numbers from right to left. If either product becomes zero (because of encountering a zero in the array), it resets that product back to 1. This allows the calculation to restart after zeros. At every step, it updates the answer (maxi) with the maximum value seen so far between the prefix product, the suffix product, and the previous maximum. After traversing the array, the final maximum product of any contiguous subarray is returned. ⏱ Time Complexity The code makes a single loop over the array of length n. Inside the loop, all operations are constant-time (multiplication, comparison, assignment). So, Time Complexity = O(n). 💾 Space Complexity Only a few variables are used: prefix, suffix, maxi, n. No extra data structures are created that depend on input size. So, Space Complexity = O(1) (constant space). ✅ Final Answer: Time Complexity: O(n) Space Complexity: O(1)