Skip to content

Instantly share code, notes, and snippets.

View anthonydmays's full-sized avatar

Anthony D. Mays anthonydmays

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Restaurants</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="restaurant.css" />
</head>
@anthonydmays
anthonydmays / sortable_indices.js
Last active September 3, 2020 05:50
Given an array of integers, write a method to find indices m and n such that if you sorted elements m through n, the entire array would be sorted. Minimize n - m (that is, find the smallest such sequence). Watch interview coach and Google engineer Anthony D. Mays solve this problem in real time on YouTube: https://youtu.be/Q8HlPVWdssk.
/**
* Given an array of integers, write a method to find indices m and n such that
* if you sorted elements m through n, the entire array would be sorted.
* Minimize n - m (that is, find the smallest such sequence).
*/
function findSortableIndices(arr) {
let i = 1;
let max = arr[0];
let minUnsorted = Number.MAX_VALUE;
if (you.gotIt(theIdea)) {
you.give(me, Gesture.HIGH_FIVE);
}