This file contains hidden or 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 insertionSort(arr: number[]) { | |
| for (let i = 1; i < arr.length; i++) { | |
| const val = arr[i] | |
| let j = i - 1 | |
| while (j >= 0 && arr[j] > val) { | |
| arr[j + 1] = arr[j] | |
| j-- | |
| } |
This file contains hidden or 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 selectionSort(arr) { | |
| for(let i=0;i<arr.length;i++){ | |
| for(let j=i+1;j<arr.length;j++){ | |
| if(arr[i]>arr[j]){ | |
| const temp=arr[i] | |
| arr[i]=arr[j] | |
| arr[j]=temp |
This file contains hidden or 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 bubbleSort(arr) { | |
| for (let i = 0; i < arr.length; i++) { | |
| let swapped = false | |
| for (let j = 0; j < arr.length - 1 - i; j++) { | |
| if (arr[j] >= arr[j + 1]) { | |
| swapped = true | |
| const temp = arr[j] | |
| arr[j] = arr[j + 1] | |
| arr[j + 1] = temp | |
| } |
This file contains hidden or 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 { useEffect, useRef, useState } from "react"; | |
| const list = [ | |
| { | |
| id: "1", | |
| title: "HTML", | |
| context: "The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser." | |
| }, | |
| { | |
| id: "2", |
This file contains hidden or 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 target = {} | |
| const handler = { | |
| get(target: Record<string, any>, property: string) { | |
| if (!Object.hasOwn(target, property)) { | |
| target[property] = `Dynamic property ${property}`; | |
| } | |
| return target[property] | |
| } |
This file contains hidden or 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 map = new Map() | |
| const target = async (property: string) => { | |
| const random = (Math.random() * (2000 - 100)) + 100 | |
| await new Promise(resolve => setTimeout(resolve, random)) | |
| console.log(`fetch ${property} detail`) | |
| return Date.now() | |
| } | |
| const handler = { | |
| apply: async (target: (property: string) => Promise<number>, thisArg: unknown, argumentList: [ string ]): Promise<number> => { |
This file contains hidden or 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 stringToZigzagGrid(text: string, numRows: number): string[][] | string { | |
| if (numRows < 2) return text | |
| const grid: string[][] = Array.from({ length: numRows }, () => []) | |
| let row = 0, col = 0, direction = "down" | |
| for (let index = 0; index < text.length; index++) { | |
| grid[row][col] = text[index] |
This file contains hidden or 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
| async function cancelOldInvitations() { | |
| const list = document.querySelectorAll(".invitation-card.artdeco-list__item"); | |
| const old = [ | |
| "Sent 1 months ago", "Sent 2 months ago", "Sent 3 weeks ago", | |
| "Sent 2 weeks ago", | |
| "Sent 3 months ago", "Sent 4 months ago", "Sent 5 months ago" | |
| ]; | |
| for (let row of [...list]) { |
This file contains hidden or 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
| interface User { | |
| _id: string; | |
| name: string; | |
| } | |
| interface State { | |
| users: User[]; | |
| addUser: (user: User) => void; |
This file contains hidden or 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 { lazy, Suspense, useEffect } from "react"; | |
| import useModalStore from "@/hooks/useModalStore.ts"; | |
| const Modal = lazy(() => import("@/components/Modal.tsx")) | |
| function Loading() { | |
| return <h2>🌀 Loading...</h2>; | |
| } | |
| function App() { |
NewerOlder