Tap here to switch tabs
Problem
Submissions

Problem: Number of Subarrays With GCD Equal to K

med
30 min
Try to solve the Number of Subarrays With GCD Equal to K problem.

Statement

Given an integer array nums and an integer k, determine the number of subarrays of nums where the greatest common divisor of all elements in the subarray equals k.

Note:
A subarray is defined as a contiguous sequence of elements within an array.
The greatest common divisor of a sequence of integers is the largest positive integer that divides each integer in the sequence without a remainder.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i], k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Subarrays With GCD Equal to K

med
30 min
Try to solve the Number of Subarrays With GCD Equal to K problem.

Statement

Given an integer array nums and an integer k, determine the number of subarrays of nums where the greatest common divisor of all elements in the subarray equals k.

Note:
A subarray is defined as a contiguous sequence of elements within an array.
The greatest common divisor of a sequence of integers is the largest positive integer that divides each integer in the sequence without a remainder.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i], k ≤109\leq 10^9