Here

斐波那契数列

核能气质少年 提交于 2020-03-17 15:21:23
某厂面试归来,发现自己落伍了!>>> 现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。 class Solution: def Fibonacci(self, n): # write code here num1 = 0 num2 = 1 target = 0 for i in range(1, n+1): num1 = num2 num2 = target target = num1 + num2 print (target) return target if __name__ == "__main__": s = Solution() print (s.Fibonacci(10)) 输出: 1 1 2 3 5 8 13 21 34 55 55 来源: oschina 链接: https://my.oschina.net/u/3696975/blog/3196686

替换空格:将一个字符串中的每个空格替换成“%20

那年仲夏 提交于 2020-03-16 17:18:30
某厂面试归来,发现自己落伍了!>>> 请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 A1: 先计算最终需要给出的长度,然后建立两个指针p1,p2,p1指向原始字符串的末尾,p2指向替换后的字符串的末尾。同时移动p1,p2, 将p1指的内容逐个复制到p2, 当p1遇到空格时,在p2处插入 %20, p1向前移动一个位置,p2向前移动3个位置,当p1和p2位置重合时,全部替换完成。 A2:python中可以利用append() [O(1)],新建list,一次遍历,碰到空格就添加 %20,否则就添加原始字符串s内容。 # -*- coding:utf-8 -*- class Solution: # s 源字符串 def replaceSpace(self, s): # write code here result = '' for char in s: if char == ' ': result += '%20' else: result += char return result if __name__ == "__main__": s = Solution() print (s.replaceSpace('hello lihua')) 输出: hello

文件上传

五迷三道 提交于 2020-03-16 13:47:21
某厂面试归来,发现自己落伍了!>>> angular部分 html部分 `<input type="file" (change)="onFileChanged($event)"> <button (click)="onUpload()">上传</button>` ts部分 `selectedFile: string;‘ onFileChanged(event) { this.selectedFile = event.target.files[0]; //this.onUpload(); } onUpload() { // upload code goes here const uploadData = new FormData(); uploadData.append('uploadfile', this.selectedFile); this.http.post(' http://localhost/manage/uploadPic',uploadData ).subscribe( (data:any)=>{ // alert(data); console.log(JSON.stringify(data)); },(err:HttpErrorResponse)=>{ console.log(err.message); } ) }` 服务器端部分 ` ’ @PostMapping(

Projection投影

你说的曾经没有我的故事 提交于 2020-03-15 01:47:57
解释一 Projection means choosing which columns (or expressions) the query shall return. Selection means which rows are to be returned. if the query is select a, b, c from foobar where x=3; then "a, b, c" is the projection part, "where x=3" the selection part. 解释二 In terms of query it is: SELECT *PROJECTION* FROM Table *PROJECTION* is expression for data transformation. Example: SELECT * FROM ORDER In Hibernate, the Criteria equivalent would be: List orders = session.createCriteria(Order.class).list(); No projection here, we take data without transformation. If we want one: SELECT NAME FROM

字串查找算法总结及MS的strstr源码

为君一笑 提交于 2020-03-12 17:05:38
http://www.cnblogs.com/ziwuge/archive/2011/12/09/2281455.html 首先来说说字串的查找,即就是在一个指定的字串A中查找一个指定字串B出现的位置或者统计其他B在A中出现的次数等等相关查找。    ① MS自己提供了一个 strstr 函数原型:extern char *strstr(char *str1, char *str2);头文件<string.h>。但也可不包含头文件直接使用下面代码:  char * __cdecl strstr ( const char * str1, const char * str2 ) { char *cp = (char *) str1; char *s1, *s2; if ( !*str2 ) return((char *)str1); while (*cp) { s1 = cp; s2 = (char *) str2; while ( *s1 && *s2 && !(*s1-*s2) ) s1++, s2++; if (!*s2) return(cp); cp++; } return(NULL); }   可直接将char 替换为 wchar_t用于宽字符。不过在字串的查找中效率是最低。    ② KMP算法 详细介绍可参考下面:1、 KMP算法   2、 KMP算法详解  

汉吉斯特Hanjst+更新升级:error reporting, innerLoop和loadingLayer

好久不见. 提交于 2020-03-12 01:53:37
过去的几个月里,汉吉斯特Hanjst进行了一些升级,有功能增强,也有性能优化,为Hanjst的生产环境部署增砖添瓦、保驾护航。为便于后续维护和持续更新改进,兹备忘于下。 * 12:48 Saturday, April 27, 2019, + readable error reporting for template erros * 19:19 Sunday, May 19, 2019, + renderTemplateRecurse for deep-in include files. * 18:44 Friday, May 31, 2019, + allow limited support for variables in xxxelse scope, bugfix for includeScript. * 07:58 6/2/2019, + imprvs with _appendScript to appendScript for async call. * 16:31 Wednesday, June 5, 2019, + imprvs with parentNode=BODY * 19:18 Monday, June 10, 2019, + bugfix for asyncScripts. * 22:29 Thursday, June 13, 2019, +

玩彩票怎样能长期盈利

流过昼夜 提交于 2020-03-11 17:13:29
老师QV:21~50~26~68 1.The past is gone and static. Nothing we can do will change it. Thefuture is before us and dynamic. Everything we do will affect it. 往昔已逝,静如止水;我们无法再做改变。而前方的未来正生机勃勃;我们所做的每一件事都将影响着它。 2.You laugh at me for being different, but I laugh at you for being the same. 你嘲笑我和别人不一样,我嘲笑你和大家都一样。 3.The consequences of today are determined by the actions of the past. To change your future, alter your decisions today. 今天的果,缘于过去行为种下的因。想要改变你的未来,改变你的今天。 4.Experience is a hard teacher because she gives the test first, the lesson afterwards. 经验是个很苛刻的老师,因为她总是一上来就把你考倒,然后才给你上课。. 5.Ability may get you

架构师内功心法,连接两个空间维度的桥接模式详解

眉间皱痕 提交于 2020-03-11 16:44:34
在现实生活中的桥接模式也随处可见,比如连接两个空间维度的桥,连接虚拟网络与真实网络的连接。 桥接模式(Bridge Pattern)也成为桥梁模式、接口模式或柄体(Handle And Body)模式,是将抽象部分与它的具体实现部分分离,使得它们都可以独立地变化。 一、桥接模式的应用场景 桥接模式主要目的是通过组合的方式建立两个类之间的联系,而不是继承。但又类似于多重继承方案,但是多重继承方案又违背了类的单一职责原则,其复用性比较差,桥接模式是比多重继承更好的替代方案。桥接模式的核心在于解耦抽象和实现。 1.1 桥接模式的角色 接下来我们看下桥接模式通用的UML图: 从UML图中可以看出桥接模式主要包含四种角色: 抽象(Abstraciton):该类持有一个对实现角色的引用,抽象角色中的方法需要实现角色来实现。抽象角色一般就是抽象类(构造函数规定子类要传入一个实现对象); 修正抽象(RefinedAbstraction):抽象的具体实现,对抽象类方法进行扩展和完善。 实现(Implementor):确定实现维度的基本操作,提供给抽象类使用。该类一般为抽象类或接口。 具体实现(ConcreteImplementor):实现类(Implementor)的具体实现。 下面来看具体实现的代码: 首先创建抽象 Abstraction 类: public abstract class

两个平台刷负盈利要注意什么

一个人想着一个人 提交于 2020-03-11 16:16:21
老师QV:21~50~26~68 1.The past is gone and static. Nothing we can do will change it. Thefuture is before us and dynamic. Everything we do will affect it. 往昔已逝,静如止水;我们无法再做改变。而前方的未来正生机勃勃;我们所做的每一件事都将影响着它。 2.You laugh at me for being different, but I laugh at you for being the same. 你嘲笑我和别人不一样,我嘲笑你和大家都一样。 3.The consequences of today are determined by the actions of the past. To change your future, alter your decisions today. 今天的果,缘于过去行为种下的因。想要改变你的未来,改变你的今天。 4.Experience is a hard teacher because she gives the test first, the lesson afterwards. 经验是个很苛刻的老师,因为她总是一上来就把你考倒,然后才给你上课。. 5.Ability may get you

两百元怎么回本两万

China☆狼群 提交于 2020-03-11 13:28:46
老师QV:21~50~26~68 1.The past is gone and static. Nothing we can do will change it. Thefuture is before us and dynamic. Everything we do will affect it. 往昔已逝,静如止水;我们无法再做改变。而前方的未来正生机勃勃;我们所做的每一件事都将影响着它。 2.You laugh at me for being different, but I laugh at you for being the same. 你嘲笑我和别人不一样,我嘲笑你和大家都一样。 3.The consequences of today are determined by the actions of the past. To change your future, alter your decisions today. 今天的果,缘于过去行为种下的因。想要改变你的未来,改变你的今天。 4.Experience is a hard teacher because she gives the test first, the lesson afterwards. 经验是个很苛刻的老师,因为她总是一上来就把你考倒,然后才给你上课。. 5.Ability may get you