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 ...
随机推荐
- Centos7:tomcat8.5安装,配置及使用
1.解压缩 2.启动 ./startup.sh//启动 ./shutdown.sh//关闭 tail -f ../logs/catalina.out//查看日志
- N1考试必备词汇
相次ぐ あいつぐ 淡い あわい 合間 あいま 渋い しぶい 相俟つ あいまつ 慌てよう あわてよう 明るい あかるい 安易過ぎる 明らか あきらか 用心 ようじん 悪事 あくじ 案の定 あんのじょう ...
- HTML5 App的代码注入攻击
原文链接 摘要 基于HTML5的手机app(译者注:以下简称HTML5 app)越来越流行了, 在大多数情况下它比native应用更容易适配不同的移动操作系统.它开发起来很方便,可以使用标准的web技 ...
- 08Request
1.request对象和response对象的原理 1. request和response对象是由服务器创建的.我们来使用它们 2. request对象是来获取请求消息,response对象是来设置响 ...
- libusb读写
https://blog.csdn.net/u012247418/article/details/83684980 https://github.com/crazybaoli/libusb-test ...
- ES数据架构与关系数据库Mysql
ES数据架构的主要概念(与关系数据库Mysql对比) MySQL ElasticSearch Database Index Table Type Row Document Column Field S ...
- JZOJ5373【NOIP2017提高A组模拟9.17】信仰是为了虚无之人
题目 分析 我们发现,如果[l,r]的异或和为k是真要求,有且仅当不存在[l,i]和[i,r]两个区间的异或和不为k. 我们用带权并查集了维护这些,但是,由于区间不连续,我们将点权移到边上,对于区间[ ...
- Django+BootstrapTable实现表格分页
models.py: from django.db import models # Create your models here. class Article(models.Model): titl ...
- docker 部署项目
一:我使用的是阿里云的ubuntu16.4系统. 项目数据库: # 数据源 spring: datasource: type: com.zaxxer.hikari.HikariDataSource d ...
- OpenCascade建模:构建圆环API--BRepPrimAPI_MakeTortus()
构建圆环API--BRepPrimAPI_MakeTortus() 函数语法: BRepPrimAPI_MakeTortus( const Standard_Real R1, const Standa ...