Skip to content

Instantly share code, notes, and snippets.

Avatar

Shaobo Hou shaobohou

View GitHub Profile
@shaobohou
shaobohou / gist:7253856
Created Oct 31, 2013
A little practice.
View gist:7253856
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cassert>
using namespace std;
namespace Merge {
@shaobohou
shaobohou / gist:7231961
Last active Dec 26, 2015
turns out my initial one pass solution was wrong, here is a corrected two-pass solution to puzzle posted in http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/
View gist:7231961
def water(heights):
vol = 0
currVol = 0
maxWall = 0
for h in heights:
if h>=maxWall:
# closed a puddle
vol += currVol
currVol = 0;
maxWall = h
View clocktest.cpp
#include <time.h>
// #include <iostream>
// #include <errno.h>
int main()
{
struct timespec tp;
int status = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
// int errsv = errno;
You can’t perform that action at this time.