') + ')', 'gi');
if (regex.test(text)) {
found = true;
var frag = document.createDocumentFragment();
var parts = text.split(regex);
parts.forEach(function(part, i) {
if (i % 2 === 0) {
frag.appendChild(document.createTextNode(part));
} else {
var span = document.createElement('span');
span.className = 'userscript-highlight';
span.textContent = part;
frag.appendChild(span);
}
});
node.parentNode.replaceChild(frag, node);
}
});
} else if (node.nodeType === 1 && node.childNodes) { // element
var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];
if (!skipTags.includes(node.tagName)) {
Array.from(node.childNodes).forEach(highlight);
}
}
}
highlight(document.body);
// Re-highlight on dynamic content
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1 || node.nodeType === 3) highlight(node);
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Strip utm_, fbclid, gclid, etc. from all links on page
(function() {
var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',
'ref', 'ref_src', 'source', 'medium', 'campaign'];
function cleanUrl(url) {
try {
var u = new URL(url, window.location.origin);
var changed = false;
trackingParams.forEach(function(p) {
if (u.searchParams.has(p)) {
u.searchParams.delete(p);
changed = true;
}
});
return changed ? u.toString() : url;
} catch (e) {
return url;
}
}
function cleanLinks() {
document.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
cleanLinks();
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1) {
if (node.tagName === 'A') cleanLinks();
node.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); }
})();
(function(){
try {
var __m = "youtube.com";
var __re = new RegExp('^' + "youtube\\.com" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Auto-enable theater mode on YouTube
(function() {
function tryTheater() {
var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]');
if (btn && !btn.classList.contains('activated')) {
btn.click();
}
}
// Try immediately
tryTheater();
// Try after navigation (SPA)
var lastUrl = location.href;
setInterval(function() {
if (location.href !== lastUrl) {
lastUrl = location.href;
setTimeout(tryTheater, 500);
}
}, 1000);
// Also try on player load
var observer = new MutationObserver(tryTheater);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Remove or un-stick sticky/fixed headers that block content
(function() {
function unstick() {
document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) {
if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {
el.style.position = 'static';
el.style.top = 'auto';
el.style.zIndex = 'auto';
}
});
}
unstick();
var observer = new MutationObserver(unstick);
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
})();
}
} catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); }
})();
})();
GitHub - TotemGuo/lintcode: LintCode题解,LintCode是LeetCode.com网站的增强版,题目更优质,覆盖知识点更多 · GitHub
Repository files navigation ##PDF下载
LintCode题解(C++版).pdf
本书即将由电子工业出版社出版,因此这个Repo更新会略落后于纸质版。欢迎大家购买纸质版,支持我持续更新本书。
C++ 文件夹下是C++版,内容一摸一样,代码是用C++写的,
Java 文件夹下是Java版,目前正在编写中,由于拖延症,不知道猴年马月能完成。
##LaTeX模板
本书使用的是陈硕开源的模板 。这个模板制作精良,很有taste,感谢陈硕 :)
##在Windows下编译
安装Tex Live 2013 http://www.tug.org/texlive/ 。把bin目录例如D:\texlive\2013\bin\win32加入PATH环境变量。
安装字体。这个LaTex模板总共使用了9个字体,下载地址 http://pan.baidu.com/s/1gdefYiJ ,有的字体Windows自带了,有的字体Ubuntu自带了,但都不全,还是一次性安装完所有字体比较方便。
安装TeXstudio http://texstudio.sourceforge.net/
(可选)启动Tex Live Manager,更新所有已安装的软件包。
配置TeXstudio。
启动Texstudio,选择 Options-->Configure Texstudio-->Commands,XeLaTex 设置为 xelatex -synctex=1 -interaction=nonstopmode %.tex;
选择 Options-->Configure Texstudio-->Build
Build & View 由默认的 PDF Chain 改为 Compile & View;
Default Compiler 由默认的PdfLaTex 修改为 XeLaTex ;
PDF Viewer 改为 “Internal PDF Viewer(windowed)”,这样预览时会弹出一个独立的窗口,这样比较方便。
编译。用TeXstudio打开lintcode-cpp.tex,点击界面上的绿色箭头就可以开始编译了。
在下方的窗口可以看到TeXstudio正在使用的编译命令是xelatex -synctex=1 -interaction=nonstopmode "lintcode-cpp".tex
##在Ubuntu下编译
安装Tex Live 2013 http://www.tug.org/texlive/
1.1. 下载TexLive 2013 的ISO 光盘,地址 http://www.tug.org/texlive/acquire-iso.html
1.2 mount 光盘,sudo ./install-tl 开始安装
1.3 加入环境变量
sudo vi /etc/profile
export PATH=$PATH:/usr/local/texlive/2013/bin/x86_64-linux
export MANPATH=$MANPATH:/usr/local/texlive/2013/texmf-dist/doc/man
export INFPATH=$INFPATH:/usr/local/texlive/2013/texmf-dist/doc/info
安装字体。这个LaTex模板总共使用了9个字体,下载地址 http://pan.baidu.com/s/1gdefYiJ ,有的字体Windows自带了,有的字体Ubuntu自带了,但都不全,还是一次性安装完所有字体比较方便。
安装TeXstudio http://texstudio.sourceforge.net/
配置TeXstudio。
启动Texstudio,选择 Options-->Configure Texstudio-->Commands,XeLaTex 设置为 xelatex -synctex=1 -interaction=nonstopmode %.tex;
选择 Options-->Configure Texstudio-->Build
Build & View 由默认的 PDF Chain 改为 Compile & View;
Default Compiler 由默认的PdfLaTex 修改为 XeLaTex ;
PDF Viewer 改为 “Internal PDF Viewer(windowed)”,这样预览时会弹出一个独立的窗口,这样比较方便。
编译。用TeXstudio打开lintcode-cpp.tex,点击界面上的绿色箭头就可以开始编译了。
在下方的窗口可以看到TeXstudio正在使用的编译命令是xelatex -synctex=1 -interaction=nonstopmode "lintcode-cpp".tex
懒人版镜像。如果不想进行上面繁琐的安装过程,我做好了一个Ubuntu VMware虚拟机镜像,已经装好了TexLive 2013, TexStudio和字体(详细的安装日志见压缩包注释),开箱即用,下载地址 http://pan.baidu.com/s/1jGj5uQi 。
##如何贡献代码
编译通过后,就具备了完整的LaTeX编译环境了。
本书模板已经写好了,基本上不需要很多LaTeX知识就可以动手了。
欢迎给本书添加内容或纠正错误,在自己本地编译成PDF,预览没问题后,就可以发pull request过来了。
##北美求职微博群
我和我的小伙伴们在这里:http://q.weibo.com/1312378
算法辅导在线视频直播课程:http://www.jiuzhang.com?source=soulmachine Leetcode在线答案:http://www.jiuzhang.com/solutions/?source=soulmachine 新一代刷题网站,比LeetCode题型更多,质量更高 :http://www.lintcode.com/?source=soulmachine
You can’t perform that action at this time.