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 / installOpenSSL.txt
Created December 23, 2016 22:46
Easy way to install OpenSSL on UNIX systems
Download from https://www.openssl.org/source/
Open terminal
Move to directory holding OpenSSL files
Type "open INSTALL"
Type "./config"
Type "make"
Type "make test"
Type "make install"
@mding5692
mding5692 / iterativeBFS.java
Created October 27, 2016 04:35
Review of BFS & DFS
// pretends Node is like this:
/* Node {
int data;
List<Integer> neighbors;
}
*/
public Node bfs(Node head, int findInt) {
Node result = new Node(-1); // null node basically
if (head == null) {
@mding5692
mding5692 / adjList.java
Created October 24, 2016 18:56
3 Graph representations - Object/Pointer, Adjacency List, Adjacency Matrix
// Uses Node class like below
/*Node(int val) {
Node next;
int val = val;
}*/
public HashMap<Integer,Node<Integer>> adjList(Pair pairArr) {
if (pairArr.length == 0) {
return null;
}
@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;
@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 / 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 / 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 / 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 / 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 / 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);
}