Skip to content

Instantly share code, notes, and snippets.

@leftrk
leftrk / bucketSort.cpp
Created January 29, 2019 06:59
桶排序
#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], )]
#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, // 当前线段的左端点
@leftrk
leftrk / gist:2b66466353d61f7232fff30181dd943d
Last active May 28, 2019 13:49
二分查找的不完全总结
/*
* 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();
@leftrk
leftrk / download.py
Created December 11, 2019 18:37
download file
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!")
@leftrk
leftrk / page.js
Created December 10, 2020 09:53
liaoxuefeng.com 左右方向键翻页
// ==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==