New Snippet
Explore
Create Account
Login
Explore
Create Account
Login
New Snippet

@repljs's Snippets

For Loop Example

// Welcome to a simple for-loop example using repljs.com
// Take a look at the evaluations on the right ->

let data = [];
for (let i = 0; i < 5; i++)
Modified 6yr ago
|
Created 6yr ago

Insertion Sort

/**
 * Insertion sort algorithm: https://en.wikipedia.org/wiki/Insertion_sort
 */
const insertionSort = (list) => {
    const items = [].concat(list); // lets create a copy, so we don't mutate the original list reference
Modified 6yr ago
|
Created 6yr ago

Binary Search

/**
 * Binary search algorithm: https://en.wikipedia.org/wiki/Binary_search_algorithm
 * Will return the index of the 'searchValue' or -1 if not found.
 */
const binarySearch = (searchValue, array) => {
Modified 6yr ago
|
Created 6yr ago

Slug Generator

/**
 * Generate a human readable slug.
 */
const VERBS = ['ask', 'build', 'buy', 'drink', 'run', 'toss'];
const COLORS = ['blue', 'green', 'orange', 'pink', 'red', 'red'];
Modified 6yr ago
|
Created 6yr ago

Binary Tree Postorder Traversal

/**
 * Problem:
 * Given a binary tree, return the postorder traversal of its nodes' values.
 *
 * Example:
Modified 6yr ago
|
Created 6yr ago

Minimum Depth of Binary Tree

/**
 * Given a binary tree, find its minimum depth.
 * The minimum depth is the number of nodes along the
 * shortest path from the root node down to the nearest
 * leaf node.
Modified 6yr ago
|
Created 6yr ago

Explore

|

Create Account

|

Login

|

Donate

Privacy Policy

|

Terms & Conditions

|

Copyright © 2018-2022 Staymark Group LLC