Skip to content

Instantly share code, notes, and snippets.

View addy's full-sized avatar
😸
Body found floating by the docks

Addison Shaw addy

😸
Body found floating by the docks
View GitHub Profile
@addy
addy / keybase.md
Created December 31, 2019 12:36
keybase.md

Keybase proof

I hereby claim:

  • I am addy on github.
  • I am metadaemon (https://keybase.io/metadaemon) on keybase.
  • I have a public key ASD3xuSGR1kRGT-uJG5YmTzEWwEzKAyEJoMzLRfLZmf1Ewo

To claim this, I am signing this object:

@addy
addy / array_degree.java
Created August 12, 2019 22:59
Degree of an Array
class Solution {
public int findShortestSubArray(int[] nums) {
if (nums.length == 0) return 0;
Map<Integer, Integer> map = new HashMap<>();
Map<Integer, int[]> positions = new HashMap<>();
int maxDegree = -1;
int minSub = Integer.MAX_VALUE;
for (int i = 0; i < nums.length; i++) {
@addy
addy / quad_tree.java
Created July 19, 2019 02:41
Quad Tree 427
class Solution {
public Node construct(int[][] grid) {
if (grid.length == 0) return null;
return dfs(grid, 0, 0, grid.length - 1, grid.length - 1);
}
private Node dfs(int[][] grid, int row1, int col1, int row2, int col2) {
if (col1 >= col2) {
return new Node(grid[row1][col1] == 1, true, null, null, null, null);
}
@addy
addy / find_permutation.java
Created July 17, 2019 02:31
find_permutation
public int[] findPermutation(String s) {
char[] c = s.toCharArray();
int[] ret = new int[c.length + 1];
int start = 0;
int low = 1;
int iIndex = 0;
while (start < c.length)
{
// Look for our first 'I', increasing "low" so that
// later when we iterate to our 'I' index, decreasing low, we don't hit 0.
@addy
addy / two_sum.rs
Created March 16, 2019 00:35
Two Sum
use std::collections::HashMap;
use std::vec::Vec;
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut seen = HashMap::new();
for (i, num) in nums.iter().enumerate() {
let val = target - num;
match seen.get(&val) {
Some(&k) => return vec![k as i32, i as i32],
@addy
addy / trie.js
Created February 19, 2019 20:45
trie.js
/*
This is just a small implementation of a Trie, used to store keys to an external map
in the 'leaves' of the tree. This can be used to make reverse lookup in a word map much
more efficient.
*/
class Node {
constructor(val) {
this.val = val;
this.children = new Map();
this.parent = null;
class Solution
{
public double[] calcEquation(String[][] equations, double[] values, String[][] queries)
{
Map<String, Map<String, Double>> graph = new HashMap<>();
double[] ret = new double[queries.length];
for (int i = 0; i < equations.length; i++) {
String first = equations[i][0];
String second = equations[i][1];
if (!graph.containsKey(first)) {
Verifying my Blockstack ID is secured with the address 1HqBxWXEih8ob6PrEH4wCDMNto4TKTcJbn https://explorer.blockstack.org/address/1HqBxWXEih8ob6PrEH4wCDMNto4TKTcJbn
@addy
addy / main.rs
Created March 6, 2018 03:35
Mandelbrot Image Maker
extern crate num;
extern crate image;
extern crate crossbeam;
use image::ColorType;
use image::png::PNGEncoder;
use num::Complex;
use std::str::FromStr;
use std::fs::File;
use std::io::Write;
@addy
addy / public.asc
Created March 6, 2018 02:11
Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBFqV6E4BDADKqAHZA4fyBWh/f8CZ6J++F3aNpiOm2otRfCINMV3Sq+Qd6AZT
bkjSDDGTnukFVcz4QMzWY69CqvOZn4dAFTewCY9oIwVmzMDFpRXPuAGttwb0dF0q
CNWJLQpdhrgCZX556hxHqohOnHMnJZL7w6gpM3kJMB6IfRSkAyIVyTFQXT8PrP8A
8CBFRh/gQSe+dmsQhyR5pYmrQj0Lt+2DnBjZx+DDQr5X1dj5uMwES+ynXB6PNzlU
TI4ChB2n3Y5PhwuH5BlJjhy0dHikhS6XCeaTry4wbKNgbIBKFvRRxTFdfQlnAbLK
s38/XvAGtlbCDmFtB5bOzqoNy1y2vlQt3BODC465Erj/vkGS/h3ua+wC4mOnkdF3