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
| 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
| 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
| 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
| // 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
| { | |
| "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;", |
OlderNewer