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
function revWithReduce(str: string): string { | |
return str.split("").reduce((acc, curr) => curr + acc, ""); | |
} | |
function revWithLoop(str: string): string { | |
let reversed = ""; | |
for (let i = str.length - 1; i >= 0; i--) { | |
reversed += str.at(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
func twoSum(nums []int, target int) []int { | |
m := make(map[int]int, len(nums)) | |
for i, x := range nums { | |
y := target - x | |
if v, ok := m[y]; ok { | |
return []int{v, 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
func isAnagram(s string, t string) bool { | |
char := make([]int, 26) | |
for _, v := range s { | |
i := int(v - 'a') | |
char[i]++ | |
} | |
for _, v := range t { | |
i := int(v - 'a') |
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
func containsDuplicate(nums []int) bool { | |
m := make(map[int]bool, len(nums)) | |
for _, num := range nums { | |
if _, ok := m[num]; ok { | |
return true | |
} else { | |
m[num] = true | |
} | |
} |
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 { ListObjectsV2Command, type _Object } from "@aws-sdk/client-s3"; | |
let size = 0; | |
let keys: _Object[] = []; | |
const BUCKET_NAME = "": | |
const OBJECTS_PREFIX = ""; | |
async function fetchObjects(StartAfter?: string) { | |
const listCmd = new ListObjectsV2Command({ Bucket: BUCKET_NAME, Prefix: OBJECTS_PREFIX, StartAfter }); |
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
<script lang="ts"> | |
import firebaseApp from '$lib/firebase'; | |
import { uploadBytes, getStorage, ref } from 'firebase/storage'; | |
const onChange = (event: Event) => { | |
const target = event.target as HTMLInputElement; | |
if (!target) return; | |
if (target.files && target.files.length > 0) { | |
const selectedFile = target.files[0]; |