Skip to content

Instantly share code, notes, and snippets.

View kevinfiol's full-sized avatar
🌔
man on the moon

kevinfiol

🌔
man on the moon
View GitHub Profile

Solutions

Arrays

Guide

  • Advantages: Store multiple elements, accessing elements is fast with index
  • Disadvantages: Adding/removing in the middle is slow because items must be shifted; act of copying new array is O(n) because everything must be iterated over

Be mindful about slicing or concatenating arrays in your code. Typically, slicing and concatenating arrays would take O(n) time. Use start and end indices to demarcate a subarray/range where possible.

@kevinfiol
kevinfiol / foo.js
Last active July 23, 2024 17:09
karat
/*
Our local radio station is running a show where the songs are ordered in a very specific way. The last word of the title of one song must match the first word of the title of the next song - for example, "Silent Running" could be followed by "Running to Stand Still". No song may be played more than once.
Given a list of songs and a starting song, find the longest chain of songs that begins with that song, and the last word of each song title matches the first word of the next one. Write a function that returns the longest such chain. If multiple equivalent chains exist, return any of them.
Example:
songs1 = [
"Down By the River",
"River of Dreams",
"Take me to the River",
@kevinfiol
kevinfiol / foo.js
Created July 16, 2024 20:47
karat samples
const counts = [ "900,google.com",
"60,mail.yahoo.com",
"10,mobile.sports.yahoo.com",
"40,sports.yahoo.com",
"300,yahoo.com",
"10,stackoverflow.com",
"20,overflow.com",
"5,com.com",
"2,en.wikipedia.org",
"1,m.wikipedia.org",
alert('hello from github');
alert('hi from github');
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
let
unstableTarball =
fetchTarball
https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz;
@kevinfiol
kevinfiol / serve.ts
Last active November 21, 2023 04:40
import { walk, existsSync } from 'https://deno.land/std@0.204.0/fs/mod.ts';
import { resolve, globToRegExp, join } from 'https://deno.land/std@0.204.0/path/mod.ts';
import { serveFile } from "https://deno.land/std@0.204.0/http/file_server.ts";
const FALLBACK = Deno.env.get('SPA_FALLBACK') || '';
const SPA_GLOBS = Deno.env.get('SPA_GLOBS') || '';
const FILES = new Map<string, string>();
const ROOT = resolve('.');
const IGNORE_GLOBS = ['**/.git/**/*', '**/.git'];
@kevinfiol
kevinfiol / denam.js
Created September 11, 2023 15:07
vyce but with a getter setter api
let comps = [],
isFn = x => typeof x === 'function';
function store(init) {
let $,
x = init,
subs = [];
return $ = {
get value() {
@kevinfiol
kevinfiol / README.md
Last active August 30, 2023 02:04
forcing HTML google

Add this uBlock Origin filter:

||google.com/search$csp=script-src 'none'

On Windows, I had to set this as the custom search URL:

https://www.google.com/search?q=%s&gbv=1&sei=1