Skip to content

Instantly share code, notes, and snippets.

View pancanin's full-sized avatar
🤠
Hiiihaaaw

pancanin

🤠
Hiiihaaaw
View GitHub Profile
@pancanin
pancanin / codekata-anagrams.cpp
Created January 3, 2022 23:13
Code Kata 6 - Anagrams
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <algorithm>
#include <sstream>
#include <chrono>
#include <set>
using namespace std::chrono;
@pancanin
pancanin / merge_master.sh
Last active August 3, 2021 11:36
Merge master/main/any into current branch bash script. Allows to specify base branch
#!/bin/bash
current_branch=$(git branch | grep "*" | awk '{ print $2 }')
git checkout $1
git pull
git checkout $current_branch
git merge $1
#include <stdio.h>
int binary_search(int arr[], size_t start, size_t end, int needle) {
if (start > end) {
return -1;
}
size_t mid = start + ((end - start) / 2);
if (arr[mid] == needle) {
@pancanin
pancanin / LevelMap.java
Created December 14, 2020 12:13
Creates a map where keys are the levels in the map and the nodes are in a list
public static Map<Integer, List<TreeNode>> getTreeLevels(TreeNode root) {
Map<Integer, List<TreeNode>> treeLevels = new HashMap<>();
DFS(root, 0, treeLevels);
return treeLevels;
}
public static void DFS(TreeNode root, int level, Map<Integer, List<TreeNode>> levelMap) {
if (root == null) {
@pancanin
pancanin / areChildren.java
Created December 14, 2020 12:12
Finds if the first parameter 'root' node is parent to all nodes in the list
/*
Find the common nodes between multiple nodes
*/
public static boolean allNodesChildren(TreeNode root, List<TreeNode> nodes) {
for (TreeNode node : nodes) {
TreeNode common = findCommonNode(root, root, node);
if (common == null) {
return false;
}
@pancanin
pancanin / FindCommonNode.java
Created December 14, 2020 11:39
Finding a 'smallest' common node in a tree
public static TreeNode findCommonNode(TreeNode root, TreeNode node1, TreeNode node2) {
if (root == null) {
return null;
}
TreeNode foundInLeft = findCommonNode(root.left, node1, node2);
if (foundInLeft != null) {
return foundInLeft;
}
package io.kubeless;
import io.kubeless.Event;
import io.kubeless.Context;
public class test-sum-1 {
public String main(io.kubeless.Event event, io.kubeless.Context context) {
return "Hello world!";
}
}
empty_cell = -1
right_diag = 0
left_diag = 1
grid_width = grid_height = 3
target = 6
top_left_corner_offset = 0
top_right_corner_offset = 1
bottom_right_corner_offset = 5
bottom_left_corner_offset = 4
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AnimalShelter</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
const fs = require('fs-extra');
const concat = require('concat');
(async function build() {
const fileNames = ['runtime', 'polyfills', 'main', 'styles'];
const jsVersion = ['es5', 'es2015'];
const pathToFiles = './dist/animal-list';
const files = [];
fileNames.forEach(fn => {
jsVersion.forEach(jsver => {