jackfrued / python-interview-bible Goto Github PK
View Code? Open in Web Editor NEWPython面试宝典2020版
Python面试宝典2020版
题目里提到的两个问题是不等价的
找零顺序是无关的,上台阶的走法要考虑走几格的顺序
比如change_money(5) 其实只有两种方法5, 2+3
上5格台阶的话 就有三种方法,5 = 2+3 = 3+2
permutation or combination
def more_than_half(items):
dict = {}
for item in items:
dict[item] = dict.get(item, 0) + 1
for k,v in dict.items():
if v > len(items)//2: # 题目要求多于50%
return k
如果列表前置位有多个元素不断重复相互覆盖次数,导致这些元素对于结果没有影响,那么后续的判断中相当于减小了列表的长度,后置位中的新元素只要出现次数多于减小后列表的50%,就会被作为最终结果输出,但是这种情况下的结果明显是不合题意的。
比如输入[0, 1, 0, 1, 2, 2, 3],输出结果为2
(没学多久,说错了请见谅😂)
感觉你的第4题的答案和解释不一致
最后打印出来的结果应该是
True True
True False
True
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.