@netty using while loop
class Solution {
public static int subtractProductAndSum(int n) {
return prod - sum;
}
}
You have a given two string pattern and s(word). The first string pattern contains only the symbols 0 and 1 and the second string s contains only lowercase english letters.
Lets's say that pattern matches a substring s[1..r] or s if the following 3 conditions are met:
they have equal length
for each 0 in pattern the corresponding letter in the substring is a vowel
for each 1 in pattern the corresponding letter is a consonant.
Your task is to calculate the number of substrings of s that match pattern.
Note: in this task we defines the vowels as 'a', 'e', 'i', 'o', 'u' and 'y'. All other letters are constants.
Given an integer number n, return the difference between the product of its digits and the sum of its digits.
Example 1:
Input: n = 234
Output: 15
Explanation:
Product of digits = 2 * 3 * 4 = 24
Sum of digits = 2 + 3 + 4 = 9
Result = 24 - 9 = 15
Example 2:
Input: n = 4421
Output: 21
Explanation:
Product of digits = 4 * 4 * 2 * 1 = 32
Sum of digits = 4 + 4 + 2 + 1 = 11
Result = 32 - 11 = 21