Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sourcedelica on github.
  • I am sourcedelica (https://keybase.io/sourcedelica) on keybase.
  • I have a public key ASBh_5sq4cUl7RwTvfjPzQNxdA2CULnWE6YBEzrgdTHWFQo

To claim this, I am signing this object:

import collections
class LFUCache(object):
def __init__(self, n):
self.capacity = n
self.key_to_node = dict()
self.count_to_nodes = collections.defaultdict(dict)
self.min_count = 0
@sourcedelica
sourcedelica / PalindromicDecomposition.scala
Last active November 7, 2018 02:41
Palindromic Decomposition
/**
* Compute all palindromic decompositions of a string
*
* O(n²) time and space
*/
trait PalindromicDecomposition {
type Intervals = Vector[(Int, Int)]
def decompose(s: String): Seq[String] = {
val memo = Array.ofDim[Vector[Intervals]](s.length)
@sourcedelica
sourcedelica / CMakeLists.txt
Last active September 2, 2017 05:06
Reproduce hang during ~actor_system
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(SOURCES ServerMonitor.cpp ServerMonitorTest.cpp)
set(CAF_ROOT "/usr/local/caf" CACHE PATH "CAF install directory")
set(CAF_INC ${CAF_ROOT}/include)
set(CAF_LIB ${CAF_ROOT}/lib)
set(CAF_LIBS
${CAF_LIB}/libcaf_io_static.a
@sourcedelica
sourcedelica / rainfall_challenge_dfs.py
Last active August 25, 2017 14:30
Rainfall challenge - DFS
# coding=utf-8
"""
Rainfall challenge using DFS
https://codereview.stackexchange.com/questions/38500/rainfall-challenge
O(n²) time and space
"""
import sys
import collections
@sourcedelica
sourcedelica / gist:bc4a7a4228fc606f3a75fda0f4455ade
Created July 2, 2017 03:48
My Akka docs print stylesheet
@media print {
.nav-header, nav, footer {
display: none;
}
.fixed-shift-for-large {
margin: 0;
}
@sourcedelica
sourcedelica / config.log
Created April 13, 2017 16:11
htop-2.0.2 missing -ltinfo
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by htop configure 2.0.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/develop/epederson/dev/htop-install
## --------- ##
## Platform. ##
#include "caf/all.hpp"
#include "ActorSystem.h"
using namespace caf;
using work_atom = atom_constant<atom("work")>;
using work_ok_atom = atom_constant<atom("work_ok")>;
caf::behavior serverBehavior(event_based_actor *self) {
return {
/**
* EPI 20.6
* O(n) space
* Start: O(log n)
* Cancel: O(n)
* Cancel could be improved to O(log n) using IndexedMinPQ instead of DelayQueue.
* You would also need to manage the poller thread wakeups
* and would need to synchronize on the queue.
*/
public class Timer {