File tree 2 files changed +24
-3
lines changed
solution/1200-1299/1295.Find Numbers with Even Number of Digits
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 42
42
43
43
## 解法
44
44
<!-- 这里可写通用的实现逻辑 -->
45
-
45
+ 首先将数组元素转换为字符串,判断字符串长度是否为偶数即可
46
46
47
47
<!-- tabs:start -->
48
48
57
57
<!-- 这里可写当前语言的特殊实现逻辑 -->
58
58
59
59
``` java
60
-
60
+ class Solution {
61
+ public int findNumbers (int [] nums ) {
62
+ int res = 0 ;
63
+ for (int i = 0 ; i < nums. length; i++ ) {
64
+ if (((String . valueOf(nums[i]). length()) & 1 ) == 0 ) {
65
+ res++ ;
66
+ }
67
+ }
68
+ return res;
69
+ }
70
+ }
61
71
```
62
72
63
73
### ** ...**
64
74
```
65
75
66
76
```
67
77
68
- <!-- tabs:end -->
78
+ <!-- tabs:end -->
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public int findNumbers (int [] nums ) {
3
+ int res = 0 ;
4
+ for (int i = 0 ; i < nums .length ; i ++) {
5
+ if (((String .valueOf (nums [i ]).length ()) & 1 ) == 0 ) {
6
+ res ++;
7
+ }
8
+ }
9
+ return res ;
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments