lintcode bugfree and good codestyle note
2016.12.4, 366
http://www.lintcode.com/en/problem/fibonacci/
一刷使用递归算法,超时。二刷使用九章算术的算法,就是滚动指针的思路,以前写python的时候也玩过,但是给忘了,这次又用c++拾起来了。lint有bug,不能用,很烦。
class Solution {
public:
/**
* @param n: an integer
* @return an integer f(n)
*/
int fibonacci(int n) {
int a = , b = ;
for (int i = ; i < n; i++) {
int c = a + b;
a = b;
b = c;
}
return a;
}
};
lintcode bugfree and good codestyle note的更多相关文章
- leetcode & lintcode for bug-free
刷题备忘录,for bug-free leetcode 396. Rotate Function 题意: Given an array of integers A and let n to be it ...
- leetcode bugfree note
463. Island Perimeterhttps://leetcode.com/problems/island-perimeter/就是逐一遍历所有的cell,用分离的cell总的的边数减去重叠的 ...
- leetcode & lintcode 题解
刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...
- [LintCode]——目录
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (20 ...
- (lintcode全部题目解答之)九章算法之算法班题目全解(附容易犯的错误)
--------------------------------------------------------------- 本文使用方法:所有题目,只需要把标题输入lintcode就能找到.主要是 ...
- [LintCode] Implement Trie 实现字典树
Implement a trie with insert, search, and startsWith methods. Have you met this question in a real i ...
- LintCode Subtree
原题链接在这里:http://www.lintcode.com/en/problem/subtree/ You have two every large binary trees: T1, with ...
- Lintcode: Majority Number III
Given an array of integers and a number k, the majority number is the number that occurs more than 1 ...
- (二分查找 拓展) leetcode 162. Find Peak Element && lintcode 75. Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array nums, where nu ...
随机推荐
- MIT 6.828 JOS学习笔记3. Exercise 1.2
这篇博文是对Lab 1中的Exercise 2的解答~ Lab 1 Exercise 2: 使用GDB的'si'命令,去追踪ROM BIOS几条指令,并且试图去猜测,它是在做什么.但是不需要把每个细节 ...
- 虚拟机(VMware12 pro)安装Mac OS 10.10
下载VMware12pro,Mac OS 10.10.ios,虚拟机破解: 在虚拟机中创建新虚拟机://http://cdnnn.07net01.com/linux/2016/01/1130384.h ...
- ftp下载在谷歌与火狐不同
今天ftp点击下载按钮的时候火狐可以谷歌不行,上网查了一下网友提供两种方法确实可用记录如下 1.把"ftp"开头的网址修改为”http"开头的网址,即可顺利访问2.直接保 ...
- oracle 安装
一 : 建议安装在64位机器上,程序下载地址 http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_database_1of2. ...
- 在此为LCT开一个永久的坑
其实我连splay都还不怎么会. 今天先抄了黄学长的bzoj2049,以后一定要把它理解了. 写LCT怎么能不%数据结构大神yeweining呢?%%%chrysanthemums %%%切掉大森林 ...
- requirejs(一)
RequireJs已经流行很久了,我们在项目中也打算使用它.它提供了以下功能: 声明不同js文件之间的依赖 可以按需.并行.延时载入js库 可以让我们的代码以模块化的方式组织 初看起来并不复杂. 在h ...
- [BZOJ1501][NOI2005] 智慧珠游戏
Input 文件中包含初始的盘件描述,一共有10行,第i行有i个字符.如果第i行的第j个字符是字母”A”至”L”中的一个,则表示第i行第j列的格子上已经放了零件,零件的编号为对应的字母.如果第i行的第 ...
- 转:AngularJS的Filter用法详解
Filter简介 Filter是用来格式化数据用的. Filter的基本原型( '|' 类似于Linux中的管道模式): {{ expression | filter }} Filter可以被链式使用 ...
- Linux安装软件时缺少依赖包的简单较完美解决方法!
大家在linux下源码安装时,有木有经常碰到缺少这个包那个包的,然后不知所措?看到最近有几个筒子安装thrift,安装python因缺少依赖包而进行不下去了.我用的是红帽,装系统的时候习惯把所有的有的 ...
- HttpPostedFile类的使用方法
HttpPostedFile注意事项: (1) HttpPostedFile提供对客户端已上载的单独文件的访问. (2) 对于客户端已上载的文件,最好先保存到服务器,再访问:而不是直接访问 ...