Skip to content

Instantly share code, notes, and snippets.

View y785's full-sized avatar
๐Ÿ’—
easy (like sunday morning)

y785

๐Ÿ’—
easy (like sunday morning)
  • United States
View GitHub Profile
@y785
y785 / Solution.java
Created October 21, 2019 13:05
Guess the Word solution, top 0.04%
/**
* Runtime: 1 ms, faster than 99.96% of Java online submissions for Guess the Word.
* Memory Usage: 27.2 MB, less than 7.41% of Java online submissions for Guess the Word.
* Solution for: https://leetcode.com/problems/guess-the-word/
*/
class Solution {
public void findSecretWord(String[] wordlist, Master master) {
int secretLength = wordlist[0].length();
int length = wordlist.length;
Random rand = ThreadLocalRandom.current();
@y785
y785 / SnapshotArray.java
Created October 21, 2019 13:03
SnapshotArray challenge, solution for top 0.06%
/**
* Runtime: 68 ms, faster than 99.94% of Java online submissions for Snapshot Array.
* Memory Usage: 72.5 MB, less than 100.00% of Java online submissions for Snapshot Array.
* Solution for: https://leetcode.com/problems/snapshot-array/
*/
class SnapshotArray {
private int snaps;
private Map<Integer, Integer> map;
public SnapshotArray(int length) {
public class AESCipher {
private static final Logger log = LoggerFactory.getLogger(AESCipher.class);
private final SecretKey key;
private final MoeIV iv;
private final SecureRandom random;
private final Cipher cipher;
private final byte[] pool;
@y785
y785 / Crypto.java
Last active September 20, 2019 15:44
public interface Crypto {
/**
* The decryption cipher.
*/
AESCipher decryption();
/**
* The encryption cipher.
*/
@y785
y785 / SparkFromRetro.java
Last active September 9, 2019 08:12
A mapper for Retrofit2 annotations into Spark REST. Tries to match Retrofit2 "Call<T> name(params)" with "T name(params)" for provided class.
/**
* A /simple/ wrapper class for going from Retrofit2 <-> Spark.
* All of my Retrofit/Rest interfaces have methods that have the
* same name as their default implementations.
* See {@link moe.maple.services.base.rest.AccountRest} and {@link AccountService}
*/
public class SparkFromRetro {
private static final Logger log = LoggerFactory.getLogger( SparkFromRetro.class );