This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name liaoxuefeng.com 左右方向键翻页 | |
// @description liaoxuefeng.com 教程 增加翻页功能 | |
// @namespace Big Scripts | |
// @match *://www.liaoxuefeng.com/wiki/* | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.5.1.min.js | |
// @version 0.0.1 | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def downloadFILE(url, name): | |
resp = requests.get(url=url, stream=True) | |
content_size = int(resp.headers['Content-Length']) / 1024 | |
with open(name, "wb") as f: | |
print("File total size is:", content_size, 'k,start...') | |
for data in tqdm(iterable=resp.iter_content(1024), total=content_size + 1, unit='k', desc=name): | |
f.write(data) | |
print(name + " download finished!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 1. right = nums.size() | |
* 2. left < right | |
* 3. right = mid | |
* 4. return right | |
*/ | |
int find(vector<int> &nums, int target) { | |
int left = 0, right = nums.size(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "leetcode.h" | |
class Solution { | |
public: | |
// 关键点:把 nums 塞入 value 中 | |
void build_segment_tree(vector<int> &value, // 线段数组 value, 存储区间 sum | |
vector<int> &nums, // 原始数组 nums | |
int pos, // 当前线段【节点】在线段数组 value 中的下标 | |
int left, // 当前线段的左端点 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CATCH_CONFIG_MAIN | |
//#include "catch.hpp" | |
/** | |
* function bucket-sort(array, n) is | |
* bucket <- new array of n empty lists | |
* | |
* for i = 0 to (length(array)-1) do | |
* insert array[i] into buckets[msbits(array[i], )] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Object> | |
struct Node { | |
Object data; | |
Node *prev; | |
Node *next; | |
Node(const Object &d = Object{}, Node *p = nullptr, Node *n = nullptr) | |
: data{d}, prev{p}, next{n} {} | |
Node(Object &&d, Node *p = nullptr, Node *n = nullptr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Object> | |
class Vector { | |
private: | |
int theSize; | |
int theCapacity; | |
Object *objects; | |
static const int SPARE_CAPACITY = 16; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long long pow(long long x, int n) { | |
if (n == 0) | |
return 1; | |
if (n == 1) | |
return x; | |
if (n & 0x1) | |
return pow(x * x, n / 2) * x; | |
else | |
return pow(x * x, n / 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long long gcd(long long m, long long n) { | |
while (n != 0) { | |
long long rem = m % n; | |
m = n; | |
n = rem; | |
} | |
return m; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param a | |
* @param left | |
* @param right | |
* @return maxSum between left and right | |
* @brief 相连最大子序列和的递归算法 | |
* @note 找出生成 [left ... right] 的子数组的最大和,不试图保留具体的最佳序列 | |
*/ | |
int maxSumRec(const vector<int> &a, int left, int right) { | |
if (left == right) // 基准情形 |
NewerOlder