2748. Number of Beautiful Pairs
You are given a 0-indexed integer array
nums. A pair of indicesi,jwhere0 <= i < j < nums.lengthis 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
xandyare coprime if there is no integer greater than 1 that divides both of them. In other words,xandyare coprime ifgcd(x, y) == 1, wheregcd(x, y)is the greatest common divisor ofxandy.
1 | class Solution { |