mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
34 lines
1.0 KiB
HTML
34 lines
1.0 KiB
HTML
<p>Given an array <code>nums</code> of integers, return how many of them contain an <strong>even number</strong> of digits.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [12,345,2,6,7896]
|
|
<strong>Output:</strong> 2
|
|
<strong>Explanation:
|
|
</strong>12 contains 2 digits (even number of digits).
|
|
345 contains 3 digits (odd number of digits).
|
|
2 contains 1 digit (odd number of digits).
|
|
6 contains 1 digit (odd number of digits).
|
|
7896 contains 4 digits (even number of digits).
|
|
Therefore only 12 and 7896 contain an even number of digits.
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [555,901,482,1771]
|
|
<strong>Output:</strong> 1
|
|
<strong>Explanation: </strong>
|
|
Only 1771 contains an even number of digits.
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums.length <= 500</code></li>
|
|
<li><code>1 <= nums[i] <= 10<sup>5</sup></code></li>
|
|
</ul>
|