Skip to content

Instantly share code, notes, and snippets.

#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool covered(const vector<string>& filters, const string& line)
{
@richzw
richzw / gist:4965829
Created February 16, 2013 06:35
BackTrack
排列的问题,求一个集合元素的全排列。
整数集合s和一个整数sum,求集合s的所有子集su,使得su的元素之和为sum
1 #include <iostream>
2
3 using namespace std;
4
5
@richzw
richzw / LinkList.c
Last active December 14, 2015 05:48
basic operation function for single link list.
@richzw
richzw / SkipList.c
Created March 1, 2013 09:03
implement of skiplist
#ifndef __SKIPLIST_H
#define __SKIPLIST_H
#define SKIPLIST_MAXLEVEL 8
typedef struct skiplistNode {
double score;
struct skiplistNode *backward;
struct skiplistLevel {
struct skiplistNode *forward;
//For sparse matrix
typedef struct QLNode
{
int iPos, jPos; //非零元素的行列下标;
int iElem; //元素;
struct QLNode *right, *down;
}QLNode;
typedef struct QLNode* QLink;
@richzw
richzw / InsertSort
Created April 1, 2013 02:57
loop version and recursive version
34 void insertSort(int a[], int len){
35 for (int j = 1; j < len; ++j){
36 int key = a[j];
37 int i = j - 1;
38 while(i >= 0 && a[i] > key){
39 a[i+1] = a[i];
40 i--;
41 }
42 a[i+1] = key;
43 }
@richzw
richzw / findAscend.cpp
Created April 8, 2013 04:38
Given a array of integers , find 3 indexes i, j, k such that, i<j<k and a[i] < a[j]< a[k]. Could you find possible O(n) algorithm.
/*
* @func: find the ascends element from array
* @params: arr{array}, the given array,
* len{int}, the length of array
* pos{int}, the first position that finding the ascending elements
*/
43 void findAscend_(int arr[], int len, int pos){
44 int index_array[ARRLEN] = {0};
45 int current_max = 0;
46 int current_max_index = 0;
@richzw
richzw / bsearch.c
Created February 18, 2014 01:32 — forked from cloudwu/bsearch.c
int
binary_search_first_position(int *A, int n, int target) {
int end[2] = { -1, n };
while (end[0] + 1 < end[1]) {
int mid = (end[0] + end[1]) / 2;
int sign = (unsigned)(A[mid] - target) >> 31;
end[1-sign] = mid;
}
int high = end[1];
if (high >= n || A[high] != target)
# EDIT: 2013/10/20
# google has updated its kwt UI, this script doesn't work any more!
# may be I will update this script when I have time to investigate their new Interface.
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
import selenium.webdriver.support.wait
selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05
import re
// EDIT: 2013/10/20
// google has updated its kwt UI, this script doesn't work any more!
// may be I will update this script when I have time to investigate their new Interface.
// requires
var utils = require('utils');
var casper = require('casper').create()
var casper = require('casper').create({
verbose: true,