billryan / algorithm-exercise Goto Github PK
View Code? Open in Web Editor NEWData Structure and Algorithm notes. 数据结构与算法/leetcode/lintcode题解/
Home Page: https://algorithm.yuanbin.me
Data Structure and Algorithm notes. 数据结构与算法/leetcode/lintcode题解/
Home Page: https://algorithm.yuanbin.me
It is a long time since I decided to design this ebook cover. After some discussion with @niangaotuantuan , I designed 4 different cover pictures for this useful algorithm notes. @kokdemo contributed his new design(No.1). Which one do you like best? I prefer the second one. :)
Serious and Powerful.
Graceful and vivid.
Heavy.
I wrote a site search plugin for gitbook, which can be found in https://github.com/billryan/gitbook-plugin-swiftype. It works well when loading a new page or refreshing the old page, but it does not work for 'page.change' event in Gitbook. Anyone can give a hint?
咱两的思路不一样
class NewNode:
def init(self, val):
self.value = val
self.next = next
def judge_circle(self, head):
slow = head
fast = head
while slow and fast:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
if fast and slow and (fast == slow):
return True
else:
return False
我的就直接 fast = fast.next.next了
看了 lz 的 repo,觉得我的可以不用弄了,逐渐把我笔记和代码里有用的东西搬运过来。
Gitbook do not render the files outside language folders now, a workaround for this issue is found in GitbookIO/gitbook#744.
Now you can refer an image or docs like this:
![Queen](../../shared-files/images/8-queens.png)
The workaround is broken for EPUB/PDF/MOBI, replace with
![Queen](https://raw.githubusercontent.com/billryan/algorithm-exercise/master/shared-files/images/8-queens.png)
Long term schedule
我看了 travis 文件,没有看到同步七牛的部分……整个 repo 里有一个 qiniu_sync.json
,但是里面的密钥肯定不能用。特别想知道你怎么把自动同步到了七牛 😄 。
笔记:basics_sorting/quick_sorting.md
比较alist[i]和alist[l]时只能使用<而不是<=! 因为只有取<才能进入收敛条件,<=则可能会出现死循环,因为在=时第一个元素可能保持不变进而产生死循环。
我分析写 <=
并不会出现死循环,用这种方式提交了 leetcode 215 题 Kth Largest Element in an Array, 也能通过~
Misspelling of exercise, the repo name algorithm-excercise
should be algorithm-exercise
. %>_<%
I did use bfg to shrink the size of this repo local, but it seems like it did not work at all in the GitHub side. Anyone has a clue? Do I need remove this repo and create another new one based on my local history?
P.S. 我明天放寒假回家,上网和收发邮件不太方便,其他 Collaborator 可以将合适的 Pull Request 合并到 master。
The Chinese fonts used in PDF version is unreadable. Proper Chinese fonts such as [文泉驿]([Habitat: MicroHei]%28http://wenq.org/wqy2/index.cgi?MicroHei%29) would be better. I do not find the way how to modify the Chinese fonts rendered for PDF, anybody can give a hint?
目前的 PDF 版字体巨丑无比,简直不忍直视!最好的办法就是等官方更新他们的系统字体了,本地测试生成的字体还不错。如果要离线查看本文档,目前还是比较推荐 epub 和离线的 html。
目前已使用 travis-ci.org 生成PDF/EPUB/HTML/MOBI,可以自行添加字体。将生成的 PDF/EPUB/MOBI/HTML 自动同步到七牛上,方便下载。
Sitemap.xml is an optimization for search engine. Gitbook does not provide sitemap support now. I have little knowledge about Javascript, so I wrote a sitemap generation helper with Python.
git ls-tree
and git log
, we can get the files in git repo and its latest modified time..md
source files and exclude/replace some special markdown files..md
with .html
.Currently you can subscribe https://github.com/billryan/algorithm-exercise/commits/master.atom for updates. Since the atom feed only shows commits title without the page contents, I decided developing a simple GitHub RSS feed generator for diff and full-text. You can refer Updates - Data Structure and Algorithm for more details.
GitHub RSS project: https://github.com/billryan/github-rss
Add new sections by GitbookIO editor is quite simple, but sometimes you may forget to add sections in SUMMARY.md.
It is easy to parse the title of source .md files and add it to the appropriate chapter position. I will implement this feature with Python.
Since https://github.com/GitbookIO/plugin-versions rely on GitBook API and is more suitable for multi-version software API, we need a multilingual selection plugin for gitbook pages.
Some JS or CSS we can refer:
gitbook.toolbar.createButton
APIAccording to GitbookIO/gitbook#926, the $lang zh-cn
have been removed from Gitbook, we should use zh-hans
instead.
zh-tw
should be zh-hant
but gitbook does not support now.
Static files such as PDF are deployed in Gitbook and my DigitalOcean VPS, but it is a bit complex to maintain the scripts and difficult to access from mainland China.
The new architecture will be:
目前的 PDF 静态文件是通过自己的 VPS 和 Travis 编译输出的,实测自己的 VPS 性能还是比不过 Travis. 使用思源黑体后 PDF 占用字节空间达30MB+, 国内用户访问这些国外网站速度都非常慢,放在七牛云存储上的文件因为流量太大把我的免费额度快用完了... 因此想将静态文件直接放到 GitHub(主要用于国外用户) 和 GitCafe(镜像 GitHub 并主要用于服务国内用户),为避免污染 master 分支,这些静态文件输出都将放到另一个分支。
It is a new feature about writing style of problem description. Add problem description is a tedious work.
As a programmer, we should avoid writing monotonous, repetitive tasks. Here it comes! parse_source.py
The new writing style of problem can be found in Gray Code.
python scripts/parse_source.py problem_url
You can redirect the standard output to your clipboard or pbcopy
or some file in your disk.
python scripts/parse_source.py http://www.lintcode.com/en/problem/word-ladder/
You will get the following text from the standard output.
Given two words (_start_ and _end_), and a dictionary, find the length of
shortest transformation sequence from _start_ to _end_, such that:
1. Only one letter can be changed at a time
2. Each intermediate word must exist in the dictionary
#### Example
Given:
_start_ = `"hit"`
_end_ = `"cog"`
_dict_ = `["hot","dot","dog","lot","log"]`
As one shortest transformation is `"hit" -> "hot" -> "dot" -> "dog" -> "cog"`,
return its length `5`.
#### Note
* Return 0 if there is no such transformation sequence.
* All words have the same length.
* All words contain only lowercase alphabetic characters.
Paste or redirect to your markdown file, have fun with this new feature. 👍
flake8 testing of https://github.com/billryan/algorithm-exercise on Python 3.7.1
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./scripts/ojhtml2markdown.py:22:26: F821 undefined name 'title'
content = '# ' + title
^
./scripts/ojhtml2markdown.py:23:36: F821 undefined name 'metadata'
yaml_content = YamlContent(metadata, content)
^
2 F821 undefined name 'title'
2
The following pages are returning 404 errors.
https://algorithm.yuanbin.me/zh-hans/linked_list/delete_node_in_the_middle_of_singly_linked_list
https://algorithm.yuanbin.me/zh-hans/basics_algorithm/counting_problem
https://algorithm.yuanbin.me/zh-hans/dynamic_programming/egg_dropping_puzzle
https://algorithm.yuanbin.me/zh-hans/data_structure/kth_smallest_number_in_sorted_matrix
https://algorithm.yuanbin.me/zh-hans/problem_misc/n_queens
https://algorithm.yuanbin.me/zh-hans/problem_misc/n_queens_ii
https://algorithm.yuanbin.me/zh-hans/appendix_ii_system_design
I implemented this feature via Flask ==> https://github.com/billryan/heroku4ds-algo
You can access it via https://heroku4ds-algo.herokuapp.com/
链表中的快慢指针有问题,fast = fast.next.next吧,而不是fast = fast.next
有没有必要加个tab navigation? 类似九章上面的,http://www.jiuzhang.com/solutions/anagrams/。
把C++、python、java代码分tab显示, 我觉得这样会让页面更简洁一点
The font family used in gitbook web version are unfriendly to unicode fonts such as Chinese character.
The font-family
is set by default as
font-family:"Open Sans","Clear Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
which looks ugly on Windows platform. I should use some extra plugin to solve this problem.
简单来讲就是目前的 Gitbook 网页版生成的中文字体显示效果不好,OS X/Linux 下还算可以,Windows 下的渲染效果则惨不忍睹。
另外对于非中文的字体,计划使用 Webfont 来解决,尤其是代码部分,使用source code pro
等字型将大大提高代码的可读性和观赏性。Reference 中的 yahei 还算凑合,不过我想将它扩充到支持 Windows/Linux/OS X/Android/iOS 等多个平台,而不仅仅只是对 Windows 用户用好。嗯,这样的话就得写 js 插件了,过些天找好实习了就来 fork 一个,有略懂前端的小伙伴愿意协作的咩?
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.