
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Since nums.length is small, you can find all pairs of indices and check if each pair is beautiful.
Use integer to string conversion to get the first and last digit of each number.