title | tags | excerpt | dateModified | |
---|---|---|---|---|
JS Big-O Cheat Sheet |
|
Learn everything you need to know about Big-O notation with this handy cheatsheet. |
2023-01-08 05:00:00 -0400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" using :normal | |
g/^\\s\*DEBUG/exe "norm! I/\* \\<Esc>A \*/\\<Esc>" | |
" using :substituting | |
g/^\\s\*DEBUG/s!.\*!/\* & \*/! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:g/^/pu =\\"\\n\\" | |
" Alternative (:put inserts nothing from the blackhole register) | |
:g/^/pu \_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:g/^\\s\*$/d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:g!/pattern/d | |
:v/pattern/d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:g/pattern/d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Display context (5 lines) for all occurrences of a pattern. | |
:g/pattern/z#.5 | |
" Same, but with some beautification. | |
:g/pattern/z#.5|echo "==========" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sorts an array using the heapsort algorithm. | |
* Heapsort is a comparison-based sorting algorithm. | |
* Heapsort is an improved selection sort consisting of the use of a | |
* heap data structure instead of a linear-time search to find the maximum or minimum element. | |
* | |
* @param {Array} arr - The array to be sorted. | |
* @return {Array} - The sorted array. | |
*/ | |
function heapsort(arr) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a list of strings based on the given integer input. | |
* | |
* @param n the maximum integer value to generate strings for | |
* @return a list of strings containing the generated values | |
*/ | |
public List<String> fizzBuzz(int n) { | |
List<String> res = new ArrayList<>(n) | |
for (int i = 1; i <= n; i++) { | |
StringBuilder sb = new StringBuilder() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let asciiValue: String = "1234567890ABCDEFGHIJ" | |
func asciiToHex(_ asciiValue: String) -> String { | |
let chars: [String.Element] = Array(asciiValue) | |
var hex: String = "" | |
for char: String.Element in chars { | |
hex += String(char.asciiValue!, radix: 16) | |
} | |
return hex | |
} |