Skip to content

Instantly share code, notes, and snippets.

View isaiah-perumalla's full-sized avatar

isaiah isaiah-perumalla

View GitHub Profile
--------------------------- MODULE concurrent_map ---------------------------
EXTENDS TLC, Integers, FiniteSets, Sequences
ReaderCount == 2
Readers == 1..ReaderCount

Keybase proof

I hereby claim:

  • I am isaiah-perumalla on github.
  • I am isaiah_p (https://keybase.io/isaiah_p) on keybase.
  • I have a public key ASB2WZfQUWqLR4Aci20nORmizByne74eM-xm_t-EX9diowo

To claim this, I am signing this object:

package com.company;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
public static final int INF = Integer.MAX_VALUE;
public static void main(String[] args) {
package practice;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import practice.BinarySearchTree.Node;
public class BSTPrint {
@isaiah-perumalla
isaiah-perumalla / functions.py
Last active November 26, 2019 16:20
some python functions
def calc_avg(items):
if not items:
return 0
total = sum(items)
return float(total)/len(items)
def std_deviation(items):
if not items: return 0
mean = calc_avg(items)
@isaiah-perumalla
isaiah-perumalla / q-funcs.q
Last active November 6, 2019 20:10
some q functions
//function return all subset of a list
sset: {[xs] (enlist ()) {x, (y,) each x }/ xs}
//or using the map each right /:
sset: {[xs] (enlist ()) {x, y ,/: x }/ xs}
//q)sset (1; 2; 3;`a)
()
,1
,2
2 1

Keybase proof

I hereby claim:

  • I am isaiah-perumalla on github.
  • I am isaiahperumalla (https://keybase.io/isaiahperumalla) on keybase.
  • I have a public key whose fingerprint is E099 3317 C358 C9E7 6CD6 12C8 B55B AF0E 50E1 63B1

To claim this, I am signing this object:

def solution(N, A, B, C):
edges = [(C[i],A[i],B[i]) for i in xrange(len(A))]
edges.sort(key=lambda e: e[0])
maxLenAt = [0]*N
costAt = [0]*N
def updatePath(u,costu,lenu, v,costv, lenv, cost):
if costu < cost and lenu+1 > lenv:
maxLenAt[v] = lenu+1
costAt[v] = cost
@isaiah-perumalla
isaiah-perumalla / twitter_water.py
Last active August 29, 2015 14:27
twitter water fill problem, solution to problem described here https://medium.com/@bearsandsharks/i-failed-a-twitter-interview-52062fbb534b
def water_collected(A):
sortedHeights = [(x,i) for i,x in enumerate(A)]
sortedHeights.sort(key=lambda v: v[0]*-1) #sort in decreasing order
leftIdx = rightIdx = sortedHeights[0][1]
waterLevel = 0
for i in xrange(1,len(A)):
x,idx = sortedHeights[i]
if idx > rightIdx:
water = (idx-rightIdx-1)*x
@isaiah-perumalla
isaiah-perumalla / 10131_bigger_smarter.cc
Created October 6, 2014 19:25
solution to ova problem 10131
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct Elephant {
int iq, weight, index;
static bool iq_greater(const Elephant& e1, const Elephant& e2) {
return e1.iq >= e2.iq;
}
};