Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i < j. Return the number of good pairs. Example 1: Example 2: Example 3: Constraints: 1 <= nums.length <= 100 1 <= nums[i] <= 100…
Given a positive integer num consisting only of digits 6 and 9. Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6). Example 1: Example 2: Example 3: Constraints: 1 <= num…
Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Example 2: Constraints: 1 <= n <= 10^5 Solution in Python
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not…
Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Example 2: Example 3: Example 4…
Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat…
Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Example 1: Example 2…
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to…
Polar coordinates are an alternative way of representing Cartesian coordinates or Complex Numbers. A complex number is completely determined by its real part and imaginary part . Here, is the imaginary unit. A polar…