Skip to content

Commit 69559d1

Browse files
authored
Add cpp, java, cs solution (#58)
1 parent 93faf64 commit 69559d1

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int countDigit(int n) {
4+
return floor(log10(n) + 1);
5+
}
6+
7+
int findNumbers(vector<int>& nums) {
8+
int ans = 0, n = nums.size();
9+
for (int i = 0; i < n; i++) {
10+
if (!(countDigit(nums[i]) & 1))
11+
ans++;
12+
}
13+
return ans;
14+
}
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Solution {
2+
public int CountDigit(int n) {
3+
return (int)Math.Floor(Math.Log10(n) + 1);
4+
}
5+
6+
public int FindNumbers(int[] nums) {
7+
int ans = 0, n = nums.Length;
8+
for (int i = 0; i < n; i++) {
9+
if (CountDigit(nums[i]) % 2 == 0)
10+
ans++;
11+
}
12+
return ans;
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int countDigit(int n) {
3+
return (int)Math.floor(Math.log10(n) + 1);
4+
}
5+
6+
public int findNumbers(int[] nums) {
7+
int ans = 0, n = nums.length;
8+
for (int i = 0; i < n; i++) {
9+
if (countDigit(nums[i]) % 2 == 0)
10+
ans++;
11+
}
12+
return ans;
13+
}
14+
}

0 commit comments

Comments
 (0)