1137. N-th Tribonacci Number(Memory Usage: 13.9 MB, less than 100.00% of Python3)

其实思路很简单,套用一下普通斐波那契数列的非递归做法即可,不过这个成绩我一定要纪念一下,哈哈哈哈哈
代码在这儿:
class Solution:
def tribonacci(self, n: int) -> int:
a, b, c =0, 1, 1
if n is 0:
return 0
if n is 1:
return 1
if n is 2:
return 1
for i in range(2, n):
a, b ,c = b, c, a+b+c
return c
1137. N-th Tribonacci Number(Memory Usage: 13.9 MB, less than 100.00% of Python3)的更多相关文章
- 【Leetcode_easy】1137. N-th Tribonacci Number
problem 1137. N-th Tribonacci Number solution: class Solution { public: int tribonacci(int n) { ) ; ...
- SHELL:Find Memory Usage In Linux (统计每个程序内存使用情况)
转载一个shell统计linux系统中每个程序的内存使用情况,因为内存结构非常复杂,不一定100%精确,此shell可以在Ghub上下载. [root@db231 ~]# ./memstat.sh P ...
- 5 commands to check memory usage on Linux
Memory Usage On linux, there are commands for almost everything, because the gui might not be always ...
- Memory usage of a Java process java Xms Xmx Xmn
http://www.oracle.com/technetwork/java/javase/memleaks-137499.html 3.1 Meaning of OutOfMemoryError O ...
- Redis: Reducing Memory Usage
High Level Tips for Redis Most of Stream-Framework's users start out with Redis and eventually move ...
- Shell script for logging cpu and memory usage of a Linux process
Shell script for logging cpu and memory usage of a Linux process http://www.unix.com/shell-programmi ...
- hadoop的job执行在yarn中内存分配调节————Container [pid=108284,containerID=container_e19_1533108188813_12125_01_000002] is running beyond virtual memory limits. Current usage: 653.1 MB of 2 GB physical memory used
实际遇到的真实问题,解决方法: 1.调整虚拟内存率yarn.nodemanager.vmem-pmem-ratio (这个hadoop默认是2.1) 2.调整map与reduce的在AM中的大小大于y ...
- Why does the memory usage increase when I redeploy a web application?
That is because your web application has a memory leak. A common issue are "PermGen" memor ...
- Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十三)kafka+spark streaming打包好的程序提交时提示虚拟内存不足(Container is running beyond virtual memory limits. Current usage: 119.5 MB of 1 GB physical memory used; 2.2 GB of 2.1 G)
异常问题:Container is running beyond virtual memory limits. Current usage: 119.5 MB of 1 GB physical mem ...
随机推荐
- C# 数组转字符串显示
, , , , , , , }; arry[] = (] | ); string result = String.Join("", arry); Console.WriteLine ...
- 强制类型转换之String类型
㈠布尔(Boolean)类型 布尔值只有两个,主要用来做逻辑判断 true 表示真 : false 表示假 使用typeof检查一个布尔值时,会返回boolean ㈡Null和Unde ...
- 【模板】OI常用模板(待补充)
//PS:最近修改日期:2017-11-07 20:41:44 首先感觉这种模板类的东西写了还是很有意义的,毕竟时不时的可以拿出来借鉴一下. 现在因为刚开始写这一类的东西,所以说还不是很详细,若有读者 ...
- 灰度图像--图像分割 Marr-Hildreth算子(LoG算子)
学习DIP第49天 转载请标明本文出处:*http://blog.csdn.net/tonyshengtan *,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发: https:/ ...
- 认识并安装RabbitMQ(以Windows系统为例)
一.初识RabbitMQ 百度百科有这么一句话: MQ是消费-生产者模型的一个典型的代表,一端往消息队列中不断写入消息, 而另一端则可以读取或者订阅队列中的消息. MQ和JMS类似,但不同的是JMS是 ...
- HDU 5791 Two ——(LCS变形)
感觉就是最长公共子序列的一个变形(虽然我也没做过LCS啦= =). 转移方程见代码吧.这里有一个要说的地方,如果a[i] == a[j]的时候,为什么不需要像不等于的时候那样减去一个dp[i-1][j ...
- python-无联网情况下安装skt-learn
请从上到下安装 numpy importlib pytz python-dateutil pandas scipy pasty statemodels backports.functools_lru_ ...
- 使用Python进行层次聚类
使用 scipy.cluster.hierarchy.linkage进行层次聚类 from scipy.cluster.hierarchy import dendrogram, linkage,fcl ...
- Socket——实现一个简单的静态网页服务器
整体结构就是使用ServerSocket监听一个地址,当有接受到请求之后,解析请求中的资源路径.服务器资源路径存放在项目下的一个目录中,服务器会到这个目录中根据请求的路径去寻找相应的资源.如果找到了则 ...
- ccf 201409-3 字符串匹配(toupper,tolower)
ccf 201409-3 字符串匹配(toupper,tolower) 问题描述 给出一个字符串和多行文字,在这些文字中找到字符串出现的那些行.你的程序还需支持大小写敏感选项:当选项打开时,表示同一 ...