JAVA || Clean & Concise & Optimal Code || O(N) Time || Easy to Understand || 100% Faster Solution
\nclass Solution {\n    \n    public int countSubarray (int[] nums, int bound) {\n        \n        int answer = 0, count = 0;\n        \n        for (int num :
```\nclass Solution {\n    \n    public int countSubarray (int[] nums, int bound) {\n        \n        int answer = 0, count = 0;\n        \n        for (int num : nums) {\n            count = num <= bound ? count + 1 : 0;\n            answer += count;\n        }\n        \n        return answer;\n    }\n    \n    public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n        \n        return countSubarray (nums, right) - countSubarray (nums, left - 1);\n    }\n}\n```\n\nPlease help to **UPVOTE** if this post is useful for you.\nIf you have any questions, feel free to comment below.\n\n**LOVE CODING :)\nHAPPY CODING :)\nHAPPY LEARNING :)**
['Java']