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
// 4! = 4 * 3 * 2 * 1 | |
// 5! = 5 * 4 * 3 * 2 * 1 | |
// 1! = 1 | |
// 0! = 1 | |
const factorial = (num) => { | |
let total = 1; | |
for(let i = 1; i <= num; i++) { | |
total *= i; | |
} |
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
const reverseIterative = (arr) => { | |
const result = []; | |
for (let i = arr.length - 1; i >= 0; i--) { | |
result.push(arr[i]); | |
} | |
return result; | |
}; | |
const reverseRec = (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
class Node { | |
constructor(data) { | |
this.data = data; | |
this.left = null; | |
this.right = null; | |
} | |
} | |
// Every value in the Left subtree less than root | |
// Every value in the right subtree is greater than or equal to the root |
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
/** | |
* Implement a function that finds the longest palindrome in a given string. | |
* For example, in the string "My dad is a racecar athlete", the longest | |
* palindrome is "a racecar a". Count whitespaces as valid characters. Other | |
* palindromes in the above string include "dad", "ete", " dad " (including | |
* whitespace on each side of dad). | |
*/ | |
function longestPalindrome(string) {} |
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
import esbuild from "esbuild"; | |
import { readFile } from "node:fs/promises"; | |
import { fileURLToPath } from "node:url"; | |
export async function load(url, context, nextLoad) { | |
const source = await readFile(fileURLToPath(url), "utf-8"); | |
if (/\.jsx$/.test(url)) { | |
const transformedSource = await esbuild.transform(source, { | |
loader: "jsx", |
- Download Postgres:
sudo apt install postgresql
. - NOTE: Restart your terminal if you already have it open. And if you're using the terminal in VSCode, you'll have to restart VSCode to have it pick up the changes to the PATH variable.
- Run
$ psql -U postgres
in command prompt. This runs the psql command as the default "postgres" superuser. - Run:
postgres=# CREATE USER "[WINDOWS_USERNAME]" WITH PASSWORD '[PASSWORD]' SUPERUSER;
- Quit postgres:
postgres=# \q
- Run
psql postgres
and type the password you used in theCREATE USER
command
Starting/Stopping/Restarting postgres: https://stackoverflow.com/a/53062239