leetcode-easy-math-412 Fizz Buzz
mycode 99.06%
class Solution(object):
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
ops = ['Fizz','Buzz','FizzBuzz']
res = []
for i in range(n):
k = i + 1
if k%3 == 0 and k%5 == 0:
res.append(ops[2])
elif k%3 == 0 :
res.append(ops[0])
elif k%5 == 0:
res.append(ops[1])
else:
res.append(str(k))
return res
leetcode-easy-math-412 Fizz Buzz的更多相关文章
- [LeetCode&Python] Problem 412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
- 【leetcode】412. Fizz Buzz
problem 412. Fizz Buzz solution: class Solution { public: vector<string> fizzBuzz(int n) { vec ...
- Java实现 LeetCode 412 Fizz Buzz
412. Fizz Buzz 写一个程序,输出从 1 到 n 数字的字符串表示. 如果 n 是3的倍数,输出"Fizz": 如果 n 是5的倍数,输出"Buzz" ...
- LeetCode: 412 Fizz Buzz(easy)
题目: Write a program that outputs the string representation of numbers from 1 to n. But for multiples ...
- 【LeetCode】412. Fizz Buzz 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目大意 解题方法 方法一:遍历判断 方法二:字符串相加 方法三:字典 日期 [L ...
- [LeetCode] 412. Fizz Buzz 嘶嘶嗡嗡
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
- LeetCode 412. Fizz Buzz
Problem: Write a program that outputs the string representation of numbers from 1 to n. But for mult ...
- 力扣(LeetCode)412. Fizz Buzz
写一个程序,输出从 1 到 n 数字的字符串表示. 如果 n 是3的倍数,输出"Fizz": 如果 n 是5的倍数,输出"Buzz": 3.如果 n 同时是3和 ...
- LeetCode之412. Fizz Buzz
-------------------------------------------- 虽然是从最简单的开始刷起,但木有想到LeetCode上也有这么水的题目啊... AC代码: public cl ...
- LeetCode 412 Fizz Buzz 解题报告
题目要求 Write a program that outputs the string representation of numbers from 1 to n. But for multiple ...
随机推荐
- SuperMap-WebGL-坐标系及转换说明
转载自:https://blog.csdn.net/supermapsupport/article/details/89519310 一.坐标系介绍我们先来列举下Cesium中的坐标系:WGS84经纬 ...
- appium 自动化测试框架详读(一)
appium框架使用的过程记录,开始使用markdown来语法来编写,不知道博客园是否会支持markdown语法 ***1. appium原理* appium启动时,创建一个http://127.0. ...
- 配置好ssh互信还需要密码登录
通过ssh-keygen生成公私钥之后,再使用 ssh-copy-id将公钥传送到远程用户.这两步完成后,验证是否能等免密登录,发现并不能. 问题排查: 1..ssh 目录的权限应为 700 auth ...
- vmware虚拟机安装centos7.3
vmware准备 CentOS准备,这里下载的是CentOS 7.3CentOS-7-x86_64-Everything-1611.iso 创建新的虚拟机 选择自定义安装 硬件兼容性默认最新的,不用动 ...
- mysql 存储过程(二)
存储过程(Stored Procedure): 一组可编程的函数,是为了完成特定功能的SQL语句集,经编译创建并保存在数据库中,用户可通过指定存储过程的名字并给定参数(需要时)来调用执行. 优点(为什 ...
- tensorflow各版本下载地址
https://pypi.org/project/tensorflow-gpu/1.13.0/#files 把13改对你想要的版本
- C# 各个版本特性总结
历史版本 C#作为微软2000年以后.NET平台开发的当家语言,发展至今具有17年的历史,语言本身具有丰富的特性,微软对其更新支持也十分支持.微软将C#提交给标准组织ECMA,C# 5.0目前是ECM ...
- HDU - 6583 Typewriter (后缀自动机+dp)
题目链接 题意:你要打印一段字符串,往尾部添加一个字符需要花费p元,复制一段字符到尾部需要花费q元,求打印完全部字符的最小花费. 一开始想的贪心,后来发现忘了考虑p<q的情况了,还纳闷怎么不对. ...
- 【CF750E】New Year and Old Subsequence
题目大意:给定一个长度为 N 的字符串,定义一个字串是"好的",当且仅当字串中含有一个 "2017" 的子序列,且不含有 "2016" 的子 ...
- 细数meta标签的奥秘
因为看到了一个很不错的h5自适应网站,觉得很不错,于是好奇心作祟,让我翻开了它的源码一探究竟,最先研究的是它的meta标签,好了,废话不多说,以下是我总结的和比较实用的meta标签,如有错误,请多多指 ...