2748. Number of Beautiful Pairs
You are given a 0-indexed integer array
nums
. A pair of indicesi
,j
where0 <= i < j < nums.length
is called beautiful if the first digit ofnums[i]
and the last digit ofnums[j]
are coprime.Return the total number of beautiful pairs in
nums
.Two integers
x
andy
are coprime if there is no integer greater than 1 that divides both of them. In other words,x
andy
are coprime ifgcd(x, y) == 1
, wheregcd(x, y)
is the greatest common divisor ofx
andy
.
1 | class Solution { |