Class Solution
java.lang.Object
g2201_2300.s2283_check_if_number_has_equal_digit_count_and_digit_value.Solution
2283 - Check if Number Has Equal Digit Count and Digit Value.<p>Easy</p>
<p>You are given a <strong>0-indexed</strong> string <code>num</code> of length <code>n</code> consisting of digits.</p>
<p>Return <code>true</code> <em>if for <strong>every</strong> index</em> <code>i</code> <em>in the range</em> <code>0 <= i < n</code><em>, the digit</em> <code>i</code> <em>occurs</em> <code>num[i]</code> <em>times in</em> <code>num</code><em>, otherwise return</em> <code>false</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> num = “1210”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong></p>
<p>num[0] = ‘1’. The digit 0 occurs once in num.</p>
<p>num[1] = ‘2’. The digit 1 occurs twice in num.</p>
<p>num[2] = ‘1’. The digit 2 occurs once in num.</p>
<p>num[3] = ‘0’. The digit 3 occurs zero times in num.</p>
<p>The condition holds true for every index in “1210”, so return true.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> num = “030”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong></p>
<p>num[0] = ‘0’. The digit 0 should occur zero times, but actually occurs twice in num.</p>
<p>num[1] = ‘3’. The digit 1 should occur three times, but actually occurs zero times in num.</p>
<p>num[2] = ‘0’. The digit 2 occurs zero times in num.</p>
<p>The indices 0 and 1 both violate the condition, so return false.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == num.length</code></li>
<li><code>1 <= n <= 10</code></li>
<li><code>num</code> consists of digits.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
digitCount
-