Skip to content

Instantly share code, notes, and snippets.

@shaobohou
shaobohou / gist:7253856
Created October 31, 2013 17:41
A little practice.
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cassert>
using namespace std;
namespace Merge {
@shaobohou
shaobohou / gist:7231961
Last active December 26, 2015 23:39
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/
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
@shaobohou
shaobohou / clocktest.cpp
Created August 23, 2012 12:37
Clock test
#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;