Mid/SeniorArrayMath

Four Divisors

Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.

Example 1
Inputnums = [21,4,7]
Output32
Only 21 has exactly four divisors, and its divisors 1, 3, 7, and 21 sum to 32.
Example 2
Inputnums = [21,21]
Output64
Each 21 has exactly four divisors summing to 32, so the total is 64.

Constraints

  • 1 <= nums.length <= 10^4
  • 1 <= nums[i] <= 10^5

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate