Skip to content

Instantly share code, notes, and snippets.

View hk-skit's full-sized avatar
👨‍💻
On deep learning mode.

Hitesh Kumar hk-skit

👨‍💻
On deep learning mode.
View GitHub Profile
@hk-skit
hk-skit / Stack.js
Last active January 27, 2019 11:27
class Stack {
constructor() {
this.list = new LinkedList();
}
get isEmpty() {
return this.list.isEmpty;
}
/**
import { BinaryTreeNode } from './BinaryTreeNode';
export class BinaryTree {
constructor() {
this.root = null;
}
get isEmpty() {
return this.root === null;
}
export class BinaryTreeNode {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
/**
* Inserts node in level order.
*
@hk-skit
hk-skit / spiral_matrix.js
Created May 24, 2021 11:10
Print matrix in spiral order
const Direction = {
L_R: 0,
T_B: 1,
R_L: 2,
B_T: 3,
};
const spiral = (matrix) => {
if (matrix.length === 0) {
return;
// 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)) {
{
"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;",