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:
I hereby claim:
To claim this, I am signing this object:
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++) { |
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); | |
} |
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. |
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], |
/* | |
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 |
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; |
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
mQGNBFqV6E4BDADKqAHZA4fyBWh/f8CZ6J++F3aNpiOm2otRfCINMV3Sq+Qd6AZT | |
bkjSDDGTnukFVcz4QMzWY69CqvOZn4dAFTewCY9oIwVmzMDFpRXPuAGttwb0dF0q | |
CNWJLQpdhrgCZX556hxHqohOnHMnJZL7w6gpM3kJMB6IfRSkAyIVyTFQXT8PrP8A | |
8CBFRh/gQSe+dmsQhyR5pYmrQj0Lt+2DnBjZx+DDQr5X1dj5uMwES+ynXB6PNzlU | |
TI4ChB2n3Y5PhwuH5BlJjhy0dHikhS6XCeaTry4wbKNgbIBKFvRRxTFdfQlnAbLK | |
s38/XvAGtlbCDmFtB5bOzqoNy1y2vlQt3BODC465Erj/vkGS/h3ua+wC4mOnkdF3 |