Skip to content

Instantly share code, notes, and snippets.

View dmdeluca's full-sized avatar
🎯
Focusing

David DeLuca dmdeluca

🎯
Focusing
View GitHub Profile
@dmdeluca
dmdeluca / longestSubstringProblem.txt
Created April 12, 2022 13:19
PseudoCode for the Longest Substring Problem
int maxLength
int maxStart
int start
some set S
for each character C in the input string
check if this character is a repeated character (look for C in S)
if it is, repeat this:
look at the first character in my candidate substring.
remove that character from the front of the substring. (increment start)
remove that character also from S.
@dmdeluca
dmdeluca / LongestSubstringProblemWithHashSet.cs
Last active April 12, 2022 13:23
A solution to the longest substring problem using HashSet
namespace DSA {
public class LongestSubstringProblem {
public static string HashSetSolution(string input) {
if (string.IsNullOrEmpty(input))
return string.Empty;
var (candidateStart, candidateLength) = (0, 1);
var current = new HashSet<char>();
int start = 0;
@dmdeluca
dmdeluca / LongestSubstringSolution.cs
Last active April 11, 2022 04:08
Simple solution to the longest non-repeating substring problem
using System.Runtime.CompilerServices;
namespace DSA {
public class LongestSubstringProblem {
/// <summary>
/// Solves the LongestSubstringProblem in O(N) time without any generic data structures or custom data structures.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string SimpleBitMaskSolution(string input) {
@dmdeluca
dmdeluca / find_average_rent.py
Created February 27, 2022 05:58
Find the average rent (with confidence interval) for a room in Boston using Selenium
import selenium
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.common.exceptions import ElementNotInteractableException
import numpy as np
import scipy.stats as st
try:
options = Options()
@dmdeluca
dmdeluca / convert_quotes.py
Created February 16, 2022 02:32
Convert dumb quotes to smart quotes in HTML string
def convert_quotes(html: str):
"""Replace dumb quotes with smart quotes in HTML."""
# set flags to false.
# we assume that the HTML is well-formed and that we are starting at the beginning.
in_html_tag = False
in_quote = False
# convert all quotes to basic quotes. this might not be necessary,
# but it is if there is any chance the quotes in the document need
@dmdeluca
dmdeluca / Garbage.cs
Created October 5, 2021 05:04
Minimal reader interface for a data access layer
namespace Garbage
{
public class Garbage
{
public int GarbageId { get; set; }
public string Name { get; set; }
public GarbageType Type { get; set; }
}
public enum GarbageType