Skip to content

Instantly share code, notes, and snippets.

@mw-ding
mw-ding / plugin.js
Last active July 19, 2017 01:01
plugin.js
lambdalabConfig = {
url: "http://test.insight.io"
}
bundleUrl = 'https://raw.githubusercontent.com/lambdalab/plugin/master/insightio/content.bundle.js';
var loadBundle = function() {
var res = "";
var xhr = new XMLHttpRequest();
xhr.open("GET", bundleUrl, true);
@mw-ding
mw-ding / FindPathWithGivenWeight.cpp
Created May 13, 2012 06:46
FindPathWithGivenWeight.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
#include <vector>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;
@mw-ding
mw-ding / BitMerge.cpp
Created May 13, 2012 03:30
BitMerge.cpp
#include <cstdio>
void bitMerge(int &n, int &m, const int i, const int j){
// create a mask in which all bits blow i is 1, and all bit above i is 0
int maskI = 1;
maskI = maskI << i;
maskI = maskI - 1;
// create a mask in which all bits below j is 0, and all bit above j is 1
int maskJ = 1;
@mw-ding
mw-ding / IsSubTree.cpp
Created May 12, 2012 15:03
IsSubTree.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;
typedef boost::shared_ptr<NODE> NODE_PTR;
@mw-ding
mw-ding / FindNearestCommonParent.cpp
Created May 11, 2012 04:09
FindNearestCommonParent.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;
typedef boost::shared_ptr<NODE> NODE_PTR;
@mw-ding
mw-ding / FindInOrderSuc.cpp
Created May 11, 2012 03:15
FindInOrderSuc.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
boost::shared_ptr<struct node> parent;
}NODE;
@mw-ding
mw-ding / MakeListForEachLevel.cpp
Created May 10, 2012 07:02
MakeListForEachLevel.cpp
#include <iostream>
#include <vector>
#include <list>
#include <boost/smart_ptr.hpp>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;
@mw-ding
mw-ding / CreateBalancedTree.cpp
Created May 9, 2012 09:30
CreateBalancedTree.cpp
#include <iostream>
#include <vector>
#include <boost/smart_ptr.hpp>
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;
@mw-ding
mw-ding / HasPath.cpp
Created May 6, 2012 08:36
HasPath.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
#include "mwdstack.h"
namespace mwd {
typedef boost::shared_array< boost::shared_array<int> > ARRAY2D;
class Graph{
private:
@mw-ding
mw-ding / IsBalanceTree.cpp
Created May 5, 2012 13:12
IsBalanceTree.cpp
#include <iostream>
#include <boost/smart_ptr.hpp>
#include "mwdstack.h"
typedef struct node{
int value;
boost::shared_ptr<struct node> left;
boost::shared_ptr<struct node> right;
}NODE;