easyArraysPattern: Basic Array Operations

Element Count Threshold Solution

Problem Statement

You are given an array of integers and an integer threshold. Return the count of elements in the array that are greater than or equal to the threshold.

Examples

Example 1:
Input:[1, 2, 3, 4, 5], 3
Output:3
Explanation: The elements 3, 4, and 5 are greater than or equal to the threshold 3.
Example 2:
Input:[10, 20, 30, 40, 50], 25
Output:3
Explanation: The elements 30, 40, and 50 are greater than or equal to the threshold 25.
Example 3:
Input:[5, 5, 5, 5, 5], 5
Output:5
Explanation: All elements are greater than or equal to the threshold 5.

Constraints

  • 1 <= array length <= 1000
  • -1000 <= array elements <= 1000
  • -1000 <= threshold <= 1000
Time: O(n) Space: O(1)
Master coding challenges related to Arrays and solve the Element Count Threshold problem optimally.

Run, Test & Submit Code

Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.

Solve on Interactive Workspace

Tested Solutions

No solution code is currently loaded.
Complete this code in the workspace editor.