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 ...
随机推荐
- 客户端JavaScript-如何执行
客户端JavaScript程序有四部分:内联脚本.HTML事件处理程序.URL中的JavaScript.外联脚本:所有这些单独的代码共用同一个全局Window对象,它们可以看到相同的Document对 ...
- jackson注解使用心得
maven依赖: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId ...
- VirtualBox + CentOS 使用 NAT + Host-Only 方式联网
之前一直使用 VMware 作为虚拟机,这几天看<跟阿铭学Linux>,里面用的是虚拟机是 Oracle VirtualBox,也跟着安装配置一个,但是比较坑的是照着上面的配置折腾了很久才 ...
- jquery autocomplete插件
jquery autocomplete插件 https://goodies.pixabay.com/jquery/auto-complete/demo.html autocomplete-table ...
- Full exploitation of a cluster hardware configuration requires some enhancements to a single-system operating system.
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION Operating System Desi ...
- 自定义RecyclerView.ItemDecoration,实现RecyclerView的分割线效果
[转] 原文 自定义RecyclerView.ItemDecoration,实现RecyclerView的分割线效果 字数1598 阅读302 评论2 喜欢23 1.背景 RecyclerView ...
- angular前端开发环境
1.代码编辑工具 webstorm 2.断点调试工具 chrome插件Batarang 3.版本管理工具 git(仅仅是命令行工具) git小乌龟--tortoisegit(图形化工具) 首先在git ...
- 上传图片插件鼠标手cursor:pointer;不生效
问题: 只在谷歌里失效; 解决: font-size:0; 参考: http://jingyan.baidu.com/article/48b558e32fabb67f38c09a81.html htt ...
- html5 css3 loading 效果
canvas html5load1 主要思路update 实现12个点的绘制和旋转效果 var update = function() { ctx.save();// 把当前绘图状态保存起来 ct ...
- java编程题
第一题:输入字符串长度len1,字符串s1,字符串长度len2,字符串s2.从后向前比较,以最短字符串为标准,输出不同的元素的个数. 例如: 输入:s1="1,3,5" ...