qieguo2016 / algorithm Goto Github PK
View Code? Open in Web Editor NEW常用算法和数据结构讲解,面试算法题/leetcode解题,提供golang/js版本
License: MIT License
常用算法和数据结构讲解,面试算法题/leetcode解题,提供golang/js版本
License: MIT License
快排:空间复杂度上不需要再增加两个辅助数组;他的用到栈,空间复杂度是栈的使用次数就是递归次数,多出来的两个辅助数组浪费了;
这个版本像是尤雨溪老师的那个,只是去掉了splice()这个循环的js内部方法
func (rb *RingBuf) Write(p []byte) (n int, err error) {
if len(p) > len(rb.data) {
err = ErrOutOfRange
return
}
for n < len(p) {
written := copy(rb.data[rb.index:], p[n:])
rb.end += int64(written)
n += written
rb.index += written
if rb.index >= len(rb.data) { // 回到头部
rb.index -= len(rb.data)
}
}
if int(rb.end-rb.begin) > len(rb.data) {
rb.begin = rb.end - int64(len(rb.data))
}
return
}
if len(p) > len(rb.data) 应该修改为 if len(p) > cap(rb.data)
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.