Skip to content

Instantly share code, notes, and snippets.

View ws6's full-sized avatar
:shipit:
Working

Jingtao ws6

:shipit:
Working
View GitHub Profile
@ws6
ws6 / next_perm
Created January 4, 2013 21:23
next permutation
#include <algorithm>
class Solution {
public:
void nextPermutation(vector<int> &num) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<int>::iterator first, last,i , j , k;
(); ();
if(first==last) return;
; i++;
@ws6
ws6 / CountNs.c
Created January 4, 2013 21:25
count number of Ns from a fasta file
#include <stdio.h>
int main(int argc,char** argv)
{
int N=0;
int T=0;
for(;;)
{
int c=fgetc(stdin);
switch(c)
{
@ws6
ws6 / next_perm2.cc
Created January 4, 2013 21:27
next permutation II
#include <algorithm>
#include <vector>
using namespace std ;
int int_cmp(int i, int j){ return (i<j) ;}
class Solution {
public:
vector<vector<int> > permuteUnique(vector<int> &num) {
sort(num.begin(), num.end(), int_cmp ) ;
vector<vector<int> > ret;
@ws6
ws6 / heap.c
Created January 9, 2013 16:06
heapify
#include <stdlib.h>
#include <stdio.h>
int *lots; //parking lots
#define LOTSMAX 16 //lots size
void Heapify (int i, int mx);
void car_enter ();
void car_leave (int i);
void print_lots ();
@ws6
ws6 / kmp.cpp
Created January 10, 2013 06:10
a fabulous KMP tutorial
//http://dev-faqs.blogspot.com/2010/05/knuth-morris-pratt-algorithm.html
#include "PatternMatcher.h"
vector<int> PatternMatcher::computeKmpPrefix(const std::string &pattern){
int patternSize = pattern.size();
vector<int> kmpPrefix(patternSize);
size_t prefixPos = 0;
size_t suffixPos = 1;
while(suffixPos < patternSize){
@ws6
ws6 / mat.h
Created January 24, 2013 15:56
allocate multiple dimensional array in 1D. Support generic types
/*
* mat.h
* allocate multiple dimensional array into 1D
* using generic function macro
* with new/free/get functions
* created by Jingtao Liu
* 01/22/2013
*/
#ifndef _MATRIX_H
#define _MATRIX_H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Text.RegularExpressions;
namespace checkhub.libhub
{
public delegate bool processResult(object result);
public static class hub
@ws6
ws6 / designer.html
Last active August 29, 2015 14:07
designer
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
@ws6
ws6 / golang_pipe_http_response.go
Created June 23, 2020 18:05 — forked from ifels/golang_pipe_http_response.go
golang pipe the http response
package main
import (
"io"
"net/http"
"os/exec"
)
var (
BUF_LEN = 1024
@ws6
ws6 / main.go
Created August 7, 2020 00:27 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)