This file contains hidden or 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
void balanceSets() { | |
// from left to mid, elements move in to the mid | |
sum += balanceLR(left, mid, k); | |
// from mid to right, elements move out from the mid | |
sum -= balanceLR(mid, right, m - 2 * k); | |
} | |
int balanceLR(multiset<int> &l, multiset<int> &r, int n) { | |
// tracks how much should the running sum change in value | |
int diff = 0; |
This file contains hidden or 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
class Node: | |
def __init__(self, n: int): | |
self.val = n | |
self.left = self.right = None | |
def percentageUnderNum(root: Node, threshold: int, depth: int) -> float: | |
def helper(node: Node, count: int, total: int, curDepth: int) -> [int]: | |
output = [count, total] | |
if not node or curDepth > depth: | |
return output |
This file contains hidden or 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
" ============================================================================ | |
" Active plugins | |
" You can disable or add new ones here: | |
" this needs to be here, so vim-plug knows we are declaring the plugins we | |
" want to use | |
call plug#begin('~/.config/nvim/plugged') | |
" Now the actual plugins: |
This file contains hidden or 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
class Ocean: | |
def __init__(self, size): | |
self.board = [None] * (size * size) | |
self.size = size | |
self.cnt = 0 | |
def find(self, a): | |
return self.board[a] = find(self.board[a]) | |
def union(self, a, b) -> bool: |
This file contains hidden or 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
def chunked_palindrome |
This file contains hidden or 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
#include <iostream> | |
#include <set> | |
#include <vector> | |
#include <math.h> | |
using namespace std; | |
int sum_sq(int n) { | |
int n_sqrt = sqrt(n); | |
set<int> sqrs; |
This file contains hidden or 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
var findLargestLevel = (node) => { | |
// make levelObj as closure var | |
const levelObj = {}; | |
// inner function takes in node and level | |
const innerFunc = (node, level) => { | |
// if levelObj doesn't have property at this level | |
if (levelObj[level] === undefined) { | |
// create a new value, with the node inside an array | |
levelObj[level] = [node]; | |
// otherwise |