This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Priority Queue based Heap implementation in TypeScript */ | |
class BinaryHeap<T> { | |
private heapArray: T[] = []; | |
constructor(private lessThan: (a:T, b:T) => boolean) { | |
} | |
size() { | |
return this.heapArray.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq as hq | |
def generate_time_series(trips): | |
trips.sort(key=lambda x: (x[0], x[1])) | |
series = {} | |
minStartTime = [] | |
for trip in trips: | |
if minStartTime and minStartTime[0] <= trip[0]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dynamo: How to Design a Key-value Store? | |
Amazon’s Dynamo : https://www.allthingsdistributed.com/2007/10/amazons_dynamo.html | |
Eventually Consistent : https://www.allthingsdistributed.com/2007/12/eventually_consistent.html | |
Bigtable : https://research.google/pubs/pub27898/ | |
DynamoDB : https://www.allthingsdistributed.com/2012/01/amazon-dynamodb.html | |
CRDT : https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type | |
A Decade of Dynamo : https://www.allthingsdistributed.com/2017/10/a-decade-of-dynamo.html | |
Riak : https://docs.riak.com/riak/kv/2.2.0/learn/dynamo/ | |
Dynamo Architecture : https://www.youtube.com/watch?v=w96lLsbI1q8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Computing Rank of a node in a stream | |
"""Source: https://www.geeksforgeeks.org/rank-element-stream """ | |
class Node: | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
self.left_size = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Computing current rank of a node in a stream | |
class Node: | |
def __init__(self, val, left=None, right=None, left_size=0): | |
self.val = val | |
self.left = left | |
self.right = right | |
self.left_size = left_size | |
class Solution: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findDuplicateTransactions (transactions = []) { | |
transactions.sort((a, b) => new Date(a.time) - new Date(b.time)); | |
let duplicates = [] | |
let match = [] | |
let src, dst; | |
while(transactions.length > 1){ | |
src = 0 | |
dst = 1 | |
match = [src] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Salutation = {greeting: string, name: string} | |
/** | |
* @param {Salutation} | |
* @return {string} | |
*/ | |
function greet1({greeting, name}: Salutation):string{ | |
return `${greeting}, ${name}` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from heapq import heappush,heappop, heapify,_heapify_max | |
arr = [11, 8, 9, 6, 20, 5, 7, 14, 12, 3] | |
# `low` is a max-heap & `high` is a min-heap | |
low = [] | |
high = [] | |
# Init median to zero | |
median = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Another option if you want to keep the repo as is with the new commits you have added since the shallow, initial commit is this: Amend this commit with an interactive rebase. | |
Start an interactive rebase including the first (root) commit with | |
git rebase --interactive --root | |
Change the pick of the initial commit(s) to edit and save & close the file. | |
If you've cloned the repo with greater depth than 1, you may need to do the same for all of those commits. Or, alternatively, execute fixup for all of these during the interactive rebase. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = 4 | |
def print_board(board): | |
for i in range(N): | |
for j in range(N): | |
print(board[i][j], end=" ") | |
print() | |
NewerOlder