Skip to content

Instantly share code, notes, and snippets.

View mding5692's full-sized avatar
🏠
Working on personal projects

Michael D mding5692

🏠
Working on personal projects
View GitHub Profile
@mding5692
mding5692 / concurrent.futures-intro.md
Last active August 29, 2015 14:27 — forked from mangecoeur/concurrent.futures-intro.md
Easy parallel python with concurrent.futures

Easy parallel python with concurrent.futures

As of version 3.3, python includes the very promising concurrent.futures module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.

For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.

We use the context manager thusly:

with concurrent.futures.ProcessPoolExecutor() as executor:
@mding5692
mding5692 / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 20:02 — 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.
@mding5692
mding5692 / reverseLinkedList.java
Created January 29, 2016 00:13
For Western Tech Interview Prep Assignment 1 : Reverse a Linked List and Valid Palindrome
Node Reverse(Node head) {
if (head == null || head.next == null) {
return head;
}
Node curr = null;
Node nextNode = null;
while (true) {
nextNode = head.next;
head.next = curr;
curr = head;
@mding5692
mding5692 / Inorder.java
Created January 30, 2016 16:43
Western Tech Interview Prep Session 2 - Michael Ding : Includes tree traversals
void Inorder(Node root) {
if (root == null) { return;}
Inorder(root.left);
System.out.print(root.data + " ");
Inorder(root.right);
}
@mding5692
mding5692 / partitionList.java
Created February 14, 2016 21:08
partitionList - for Western Tech Interview Prep Q1
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode partition(ListNode head, int x) {
@mding5692
mding5692 / longestSubStringWithoutRepeat.java
Created September 20, 2016 03:44
2016-2017 Western Tech Interview Prep Session #1 Questions
public class Solution {
public int lengthOfLongestSubstring(String s) {
if (s.length() == 0 ) {
return 0;
}
if (s.length() == 1) {
return 1;
}
@mding5692
mding5692 / reverseBetween.java
Created September 27, 2016 03:57
Western Tech Interview Prep Session #2 Answers
public ListNode reverseBetween(ListNode head, int m, int n) {
if(m==n) {
return head;
}
ListNode curr = head;
ListNode tempM = null;
ListNode tempAfterN = null;
ListNode tempBeforeM = null;
@mding5692
mding5692 / sumRootToLeaf.java
Created September 29, 2016 04:46
Western Tech Interview Prep Session #3
public class Solution {
public int sumNumbers(TreeNode root) {
if (root == null) {
return 0;
}
int sum = 0;
return dfs(root,sum);
}
public int dfs(TreeNode root, int sum) {
@mding5692
mding5692 / partitionList.java
Created October 9, 2016 18:01
Tech Interview prep practice - answers
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode partition(ListNode head, int x) {
@mding5692
mding5692 / insert.java
Last active March 12, 2020 23:36
This will make it easier to read
Node newNode = new Node(yourString);
if (table[hashLocation] == null ) {
table[hashLocation] = newNode;
} else {
// iterate through nodes
currNode = table[hashLocation];
while (currNode.next != null ) {
currNode = currNode.next;
}
currNode.next = newNode;