Добавить
Уведомления

LeetCode 713 | Subarray Product Less Than K | Solution Explained (Java + Whiteboard)

Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 Explanation: The 8 subarrays that have product less than 100 are: [10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]. Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k. Running Time: O(N) Space Complexity: O(1) Always be pluggin: Slack Channel: https://join.slack.com/t/xavierelonleetcode/shared_invite/zt-fdzjx82o-uQgTCJtFy70OENdqOitttQ Github: https://github.com/xavierelon1 Facebook: https://www.facebook.com/xavier.hollingsworth.3 Instagram: https://www.instagram.com/xavierelon/ LinkedIn: https://www.linkedin.com/in/xavier-hollingsworth-524144127/ Twitter: https://twitter.com/elon_xavier

Иконка канала Кодовый карнавал
5 подписчиков
12+
15 просмотров
2 года назад
5 декабря 2023 г.
12+
15 просмотров
2 года назад
5 декабря 2023 г.

Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 Explanation: The 8 subarrays that have product less than 100 are: [10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]. Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k. Running Time: O(N) Space Complexity: O(1) Always be pluggin: Slack Channel: https://join.slack.com/t/xavierelonleetcode/shared_invite/zt-fdzjx82o-uQgTCJtFy70OENdqOitttQ Github: https://github.com/xavierelon1 Facebook: https://www.facebook.com/xavier.hollingsworth.3 Instagram: https://www.instagram.com/xavierelon/ LinkedIn: https://www.linkedin.com/in/xavier-hollingsworth-524144127/ Twitter: https://twitter.com/elon_xavier

, чтобы оставлять комментарии