Count contiguous subarrays whose product is at most k (LeetCode 713 variant with a non-strict inequality).
Asked in the online assessment stage. One of 3 HackerRank tasks.
Implement count_subarrays(nums, k). Given a list of positive integers nums and a positive integer k, return the number of contiguous, non-empty subarrays whose product is less than or equal to k.
def count_subarrays(nums, k):