Skip to content

Instantly share code, notes, and snippets.

View bwenzel2's full-sized avatar
⚙️

Ben Wenzel bwenzel2

⚙️
View GitHub Profile
<label class="control label checkbox">
<input type="checkbox">
<span class="indicator"></span>Checkbox Label
</label>
label {
user-select: none;
color: rgb(0, 0, 250);
cursor: pointer;
@bwenzel2
bwenzel2 / QuickSelect.txt
Created September 30, 2018 00:58
Pseudocode for the Quick Select algorithm
//This is an O(n) algorithm (linear)
Given an array A, of size n:
1. Pick a random index, p, as the pivot
2. Iterate through the array, comparing every element e to p, and counting the total number of elements before p
a. if e < p, move e to the left of p
b. if e > p, move e to the right of p
c. if e == p, leave e where it is
3. count the number of elements before p
@bwenzel2
bwenzel2 / CountUniqueWords.java
Created September 26, 2018 18:09
Java function that counts the number of unique words in a string, not including punctuation.
import java.util.HashMap;
class CountUniqueWords {
/*
* Given a string, return the number of unique (i.e., non-repeated) words in the string, not including punctuation, in O(n).
* Hyphenated words such as "case-sensitive" are considered as one word, as are contractions such as "didn't".
* NOTE: this function is NOT case-sensitive, so "Ball" and "ball" are not considered unique if both are in the string.
*/
public static int countUniqueWords(String s) {
using System.Linq;
using System.Windows.Controls;
using SharpDX.DXGI;
using SharpDX;
using SharpDX.WPF;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.D3DCompiler;
using System.Runtime.InteropServices;