Skip to content

Instantly share code, notes, and snippets.

View Coutlaw's full-sized avatar

Cass Outlaw Coutlaw

View GitHub Profile
@Coutlaw
Coutlaw / length_of_last_word.go
Last active November 29, 2021 21:58
Length of last word in a string, leetcode #58 https://leetcode.com/problems/length-of-last-word/
/*
Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string.
A word is a maximal substring consisting of non-space characters only.
Example 1:
Input: s = "Hello World"
@Coutlaw
Coutlaw / reverse_prefix.go
Created November 29, 2021 22:00
reverse the prefix in a word, leetcode #2000 https://leetcode.com/problems/reverse-prefix-of-word/
/*
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.
For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be "dcbaefd".
Return the resulting string.
Example 1:
.intercom-app,
.intercom-launcher-frame,
#intercom-container {
display: none !important;
}
button,
input,
optgroup,
select,
@Coutlaw
Coutlaw / generics.go
Last active December 17, 2021 17:42
Generics in Go
// This is a function to pull all the keys from a map and return them
// Its bad because it only works for strings right now
func getKeys(m map[string]int) []string {
var keys []string
for k := range m {
keys = append(keys, k)
}
return keys
}