Skip to content

Instantly share code, notes, and snippets.

View onelharrison's full-sized avatar

Onel Harrison onelharrison

View GitHub Profile
@onelharrison
onelharrison / linked_list_node.py
Created April 19, 2020 17:02
Definition of a linked list node
class LinkedListNode:
def __init__(self, value = None, next_node = None):
# stores the data for the current node
self.value = value
# stores a reference to the next node in the linked list
self.next_node = next_node
@onelharrison
onelharrison / reverse_linked_list_recursive_zero_nodes.py
Last active April 19, 2020 17:15
Increment of a recursive function that reverses an empty linked list
def reverse_linked_list_recursive(head):
if head is None: # handles empty linked list
return head
@onelharrison
onelharrison / reverse_linked_list_recursive_one_node.py
Last active April 19, 2020 17:14
Increment of a recursive function that reverses a 0- and 1-node linked list
def reverse_linked_list_recursive(head):
if head is None: # handles empty linked list
return head
if head.next_node is None: # handles linked list with one node
return head
@onelharrison
onelharrison / reverse_linked_list_recursive_one_node_v2.py
Last active April 19, 2020 17:23
Compact increment of a recursive function that reverses a 0- and 1-node linked list
def reverse_linked_list_recursive(head):
if head is None or head.next_node is None:
return head
@onelharrison
onelharrison / reverse_linked_list_recursive_two_node.py
Created April 19, 2020 17:23
Increment of a recursive function that reverses a 0-, 1-, and 2-node linked list
def reverse_linked_list_recursive(head):
if head is None: # handles empty linked list
return head
if head.next_node is None: # handles linked list with one node
return head
# A. label the end node as the new head node
new_head = head.next_node
@onelharrison
onelharrison / reverse_linked_list_recursive_two_node_v2.py
Last active April 19, 2020 17:30
Increment of a recursive function that reverses a 0-, 1-, and 2-node linked list
def reverse_linked_list_recursive(head):
if head is None: # handles empty linked list
return head
if head.next_node is None: # handles linked list with one node
return head
# A. label the end node as the new head node
new_head = reverse_linked_list_recursive(head.next_node)
@onelharrison
onelharrison / vscode_build.sh
Created May 23, 2020 21:51
Reproducible vscode builds
## === Backup Environment
# 1. Backup your settings.json file
#
# For total control over extension versions,
# - extensions.autoUpdate
# - extensions.autoCheckUpdates
#
# Default settings.json locations:
# - Windows: %APPDATA%\Code\User\settings.json
@onelharrison
onelharrison / replace_words.js
Created May 25, 2020 04:40
Leetcode: Replace Words
function TrieNode(char, terminal = false) {
this.char = char;
this.terminal = terminal;
this.nextChars = {};
}
function Trie() {
this.root = new TrieNode(null);
}
@onelharrison
onelharrison / bst_from_array.py
Created May 25, 2020 08:02
Leetcode: Convert Sorted Array to Binary Search Tree
class bst_node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
# assumes arr is sorted
def bst_from_array(arr):
if len(arr) == 0:
return None
@onelharrison
onelharrison / Microsoft.PowerShell_profile.ps1
Last active March 9, 2021 09:45
MS PowerShell Profile
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
if (-not (Get-InstalledModule -Name posh-git))
{
Install-Module posh-git -Scope CurrentUser
}
if (-not (Get-InstalledModule -Name oh-my-posh))
{
Install-Module oh-my-posh -Scope CurrentUser
}