IT/알고리즘
11] Leetcode 1295. Find Numbers with Even Number of Digits
깻잎쌈
2020. 6. 24. 21:05
반응형
숫자들 중에 짝수 자릿수인 숫자의 개수를 반환하는 문제.
Find Numbers with Even Number of Digits - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
고대로 해주면 된다.
class Solution {
public:
int findNumbers(vector<int>& nums) {
int ans = 0;
int sth =0;
for(int i = 0; i<nums.size(); i++){
sth = 0;
while(nums[i]){
nums[i] /=10;
sth++;
}
if(sth %2==0)
ans++;
}
return ans;
}
};
반응형