【leetcode】1295. Find Numbers with Even Number of Digits
题目如下:
Given an array
nums
of integers, return how many of them contain an even number of digits.Example 1:
Input: nums = [12,345,2,6,7896]
Output: 2
Explanation:
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.Example 2:
Input: nums = [555,901,482,1771]
Output: 1
Explanation:
Only 1771 contains an even number of digits.Constraints:
1 <= nums.length <= 500
1 <= nums[i] <= 10^5
解题思路:送分题。
代码如下:
class Solution(object):
def findNumbers(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
res = 0
for i in nums:
if len(str(i)) % 2 == 0:
res += 1
return res
【leetcode】1295. Find Numbers with Even Number of Digits的更多相关文章
- 【LeetCode】386. Lexicographical Numbers 解题报告(Python)
[LeetCode]386. Lexicographical Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...
- 【LeetCode】357. Count Numbers with Unique Digits 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- 【leetcode】Compare Version Numbers
题目描述: Compare two version numbers version1 and version2. If version1 > version2 return 1, if vers ...
- 【leetcode】Add Two Numbers
题目描述: You are given two linked lists representing two non-negative numbers. The digits are stored in ...
- 【leetcode】Compare Version Numbers(middle)
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...
- 【题解】【链表】【Leetcode】Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- 【leetcode】Add Two Numbers(middle) ☆
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- 【Leetcode】357. Count Numbers with Unique Digits
题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...
- 【leetcode】 Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
随机推荐
- [转帖] 修改nginx 默认上传文件大小
nginx默认会限制上传文件的大小为1M https://blog.51cto.com/ycgit/1563307 艺晨光关注0人评论12037人阅读2014-10-13 15:29:50 htt ...
- Linux系列(16)之系统资源的观察
1.系统资源观察 1.观察内存使用情况:free 格式: free //默认显示的单位为KBytes,显示系统的内存容量 free [-b | -k | -m | -g | -h] [-t] [ ...
- lg 1478
好多天没碰代码了,感觉忘得差不多了,没有学习感觉罪恶深重,从今天起开始补题啊啊! 简单零一背包,套模板就行. #include<bits/stdc++.h> using namespace ...
- vue—生命周期的基本介绍
Vue生命周期: 什么是生命周期: Vue 实例从创建到销毁的过程,就是生命周期.也就是从开始创建.初始化数据.编译模板.挂载Dom→渲染.更新→渲染.卸载等一系列过程,我们称这是 Vue 的生命周期 ...
- C# WebForm 屏蔽输入框的验证
按钮做界面跳转时,屏蔽输入框的验证可添加属性: CausesValidation="FALSE" <form runat="server"> &l ...
- BIOS将MBR读入0x7C00地址处(x86平台下)
BIOS将MBR读入0x7C00地址处(x86平台下) https://www.cnblogs.com/jikebiancheng/p/6193953.html http://www.ruanyife ...
- C++通用框架和库
C++通用框架和库 来源 https://www.cnblogs.com/skyus/articles/8524408.html 关于 C++ 框架.库和资源的一些汇总列表,内容包括:标准库.Web应 ...
- luogu4302字符串折叠题解--区间DP
题目链接 https://www.luogu.org/problemnew/show/P4302 分析 很明显一道区间DP题,对于区间\([l,r]\)的字符串,如果它的字串是最优折叠的,那么它的最优 ...
- SP338ROADS题解--最短路变式
题目链接 https://www.luogu.org/problemnew/show/SP338 分析 联想到不久前做过的一道题\(Full\) \(Tank\),感觉可以用优先队列做,于是写了\(d ...
- ELECTRON 打包
安装electron-packager cnpm install electron-packager -g 配置package.json "scripts": { "st ...