LeetCode 713 | Subarray Product Less Than K | Solution Explained (Java + Whiteboard)
Вставка
- Опубліковано 11 жов 2024
- 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: join.slack.com...
Github: github.com/xav...
Facebook: / xavier.hollingsworth.3
Instagram: / xavierelon
LinkedIn: / xavier-hollingsworth-5...
Twitter: / elon_xavier
Very good video...perfectly underrstood. BTW what about the slack channel??
Hi the Slack channel is currently inactive. I might try to reboot it. And thank you
If we are trying to count the number of subarrays, why not just use count++?
I truly hate these array problems... I rather have all trees and graphs on my interviews than these nonsense problems...
Bit confusing 😂