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
{ | |
"React Function Component Typescript": { | |
"prefix": "rfct", | |
"body": [ | |
"import type { FC } from \"react\"", | |
"import type { ${TM_FILENAME_BASE}Props } from \"./${TM_FILENAME_BASE}.types\"", | |
"", | |
"const ${TM_FILENAME_BASE}: FC<${TM_FILENAME_BASE}Props> = () => <div />;", | |
"", | |
"export default $TM_FILENAME_BASE;", |
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
// Given a string and a set of delimiters, reverse the words in the string while maintaining | |
// the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello". | |
// Follow-up: Does your solution work for the following cases: "hello/world:here/", "hello//world:here" | |
const reverseWords = (string, delimiters) => { | |
const aux = []; | |
let word = ''; | |
// O(n) | |
for (const str of string) { | |
if (!delimiters.has(str)) { |
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 Direction = { | |
L_R: 0, | |
T_B: 1, | |
R_L: 2, | |
B_T: 3, | |
}; | |
const spiral = (matrix) => { | |
if (matrix.length === 0) { | |
return; |
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
export class BinaryTreeNode { | |
constructor(value) { | |
this.value = value; | |
this.left = null; | |
this.right = null; | |
} | |
/** | |
* Inserts node in level order. | |
* |
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 { BinaryTreeNode } from './BinaryTreeNode'; | |
export class BinaryTree { | |
constructor() { | |
this.root = null; | |
} | |
get isEmpty() { | |
return this.root === null; | |
} |
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
class Stack { | |
constructor() { | |
this.list = new LinkedList(); | |
} | |
get isEmpty() { | |
return this.list.isEmpty; | |
} | |
/** |
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
// Generator function. | |
*[Symbol.iterator]() { | |
let current = this.head; | |
while (current !== null) { | |
const { value } = current; | |
current = current.next; | |
yield value; | |
} | |
} |
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
/** | |
* Iterator function. | |
* | |
* @returns | |
* @memberof LinkedList | |
*/ | |
[Symbol.iterator]() { | |
let current = this.head; | |
const iterable = { | |
next: () => { |
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
class Node { | |
constructor(value) { | |
this.value = value; | |
this.next = null; | |
} | |
} | |
class LinkedList { | |
constructor() { |
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
class RangeGenerator { | |
constructor({ | |
start = 0, | |
end = 1000, | |
step = 1 | |
}) { | |
this.start = start; | |
this.end = end; | |
this.step = step; |
NewerOlder