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的更多相关文章

  1. [LeetCode&Python] Problem 412. Fizz Buzz

    Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...

  2. 【leetcode】412. Fizz Buzz

    problem 412. Fizz Buzz solution: class Solution { public: vector<string> fizzBuzz(int n) { vec ...

  3. Java实现 LeetCode 412 Fizz Buzz

    412. Fizz Buzz 写一个程序,输出从 1 到 n 数字的字符串表示. 如果 n 是3的倍数,输出"Fizz": 如果 n 是5的倍数,输出"Buzz" ...

  4. LeetCode: 412 Fizz Buzz(easy)

    题目: Write a program that outputs the string representation of numbers from 1 to n. But for multiples ...

  5. 【LeetCode】412. Fizz Buzz 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目大意 解题方法 方法一:遍历判断 方法二:字符串相加 方法三:字典 日期 [L ...

  6. [LeetCode] 412. Fizz Buzz 嘶嘶嗡嗡

    Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...

  7. LeetCode 412. Fizz Buzz

    Problem: Write a program that outputs the string representation of numbers from 1 to n. But for mult ...

  8. 力扣(LeetCode)412. Fizz Buzz

    写一个程序,输出从 1 到 n 数字的字符串表示. 如果 n 是3的倍数,输出"Fizz": 如果 n 是5的倍数,输出"Buzz": 3.如果 n 同时是3和 ...

  9. LeetCode之412. Fizz Buzz

    -------------------------------------------- 虽然是从最简单的开始刷起,但木有想到LeetCode上也有这么水的题目啊... AC代码: public cl ...

  10. LeetCode 412 Fizz Buzz 解题报告

    题目要求 Write a program that outputs the string representation of numbers from 1 to n. But for multiple ...

随机推荐

  1. 网速监控-nload

    用来监控系统网卡实时网速的. 安装 yum install nload -y # 或 apt install nload -y 使用 # 直接运行默认监控第一个网卡, 使用上下方向键来切换网卡. nl ...

  2. 09 Python两种创建类的方式

    第一种比较普遍的方式: class Work(): def __init__(self,name): self.name = name w = Work('well woker') 这样就简单创建了一 ...

  3. 用原生JS写省市二级联动

    HTML代码 <select id="s1"> <option value="0">~请选择省份~</option> < ...

  4. Echarts常见问题汇总

    关于echarts使用的常见问题总结  来源:李文杨 关于echarts使用的问题总结1.legend图例不显示的问题:在legend中的data为一个数组项,数组项通常为一个字符串,每一项需要对应一 ...

  5. 借助Charles来测试移动端-下篇

    本篇是借助Charles来测试移动端的下半篇.(上篇任意门点我) 上次说到可以借助Charles来抓移动端的网络请求,接下来,我们来看一下怎么通过Charles来模拟返回,还是以网页版豆瓣为例. 先找 ...

  6. 使用Pechkin与CPechkin生成PDF

    1. Pechkin     从NuGet程序管理器中获得Pechkin,代码示例如下:             GlobalConfig config = new GlobalConfig();   ...

  7. 如何在 Ubuntu 上安装 pip

    1.为 Python 2 安装 pip 首先,确保已经安装了 Python 2. 在 Ubuntu 上,可以使用以下命令进行验证 python2 --version 如果没有错误并且显示了 Pytho ...

  8. 心态炸了,我再写一个4.1.0版本的SND实例

    maven依赖 <!-- Tests --><dependency> <groupId>org.springframework</groupId> &l ...

  9. Js 实现 多个tr 点击变色,再点击还原

    我用的是渲染页面,将自定义的值作为一个表示符判断当前状态 <!DOCTYPE html> <html> <head> <meta charset=" ...

  10. php内置函数,时间函数,字符串函数

    字符数----某一种编码下的一个文字 字节数----8位的0或1或者混合组成:显然字节占的空间大,显然一个字符至少占有一个字节,中文在utf-8至少占用3个也有可能4个字节 由上图可见,substr( ...