DSAMaster Logo
DSAMaster
BackeasyIntroduction to Arrays

Sum of Elements Greater Than K

Problem Description

Given an array of integers nums and an integer k, your task is to calculate the total sum of all elements in nums that are strictly greater than k.

Example 1
Input
quantities = [10, 75, 20, 80, 45]
Output
undefined

Explanation: The quantities greater than 27 are 75, 80, and 45. Their sum is 75 + 80 + 45 = 200.

Example 2
Input
quantities = [5, 15, 25, 30]
Output
undefined

Explanation: The only quantity greater than 27 is 30. Its sum is 30.

Example 3
Input
quantities = [10, 20, 27]
Output
undefined

Explanation: No quantities in the array are greater than 27. The sum is 0.

Constraints

  • `0 <= nums.length <= 10^5`
  • `-10^9 <= nums[i] <= 10^9`
  • `-10^9 <= k <= 10^9`
00:00
Loading...

Sign in to Solve

Access the full code editor, ThinkBuddy AI hints, and track your progress.

Sign in Free
Test Cases & Output
Enter test input here...
Click "Run Code" to execute