Skip to content

Instantly share code, notes, and snippets.

@yeedle
yeedle / CountingOccuerences.java
Last active November 27, 2016 15:12
Counting occurrences of words or chars in a string using Java 8 streams
import java.util.*;
import java.util.stream.*;
class CountingOccureences {
public static void main(String[] args) {
String example = "The quick brown fox jumps over the lazy dog and the dog catches the fox";
System.out.println(countOccurences(example.replaceAll("\\s", ""), ""));
// output: {a=3, b=1, c=3, d=3, e=6, f=2, g=2, h=5, i=1, j=1, k=1, l=1, m=1, n=2, o=6, p=1, q=1, r=2, s=2, t=5, u=2, v=1, w=1, x=2, y=1, z=1}
@yeedle
yeedle / StringToIntConversion.java
Last active November 27, 2016 02:53
Converts a number encoded as a String in any radix to an int in decimal representation using Java 8 based on http://stackoverflow.com/a/18552071/4240010
import java.util.*;
import java.util.stream.*;
import java.util.concurrent.atomic.*;
class StringToIntConversion {
public static void main(String[] args) {
String binary = "01110";
System.out.println(Integer.valueOf(binary, 2));
System.out.println(toRadix(binary, 2));
@yeedle
yeedle / The Technical Interview Cheat Sheet.md
Created November 13, 2016 04:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.