Skip to content

Instantly share code, notes, and snippets.

@coderinblack08
Created June 14, 2020 02:02
Show Gist options
  • Save coderinblack08/e863f8d04fb3d81d6b85f31d9d45c091 to your computer and use it in GitHub Desktop.
Save coderinblack08/e863f8d04fb3d81d6b85f31d9d45c091 to your computer and use it in GitHub Desktop.
// Problem Statement: 2D Peak Finder Algorithm
// Key concept: Divide and Conquer Strategy
// MIT Link: https://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf
const matrix = [
[10, 8, 10, 10],
[14, 13, 12, 11],
[15, 9, 11, 21],
[16, 17, 19, 20]
],
list = [];
// Find Max in each row
matrix.forEach(i => list.push(Math.max(...i)));
// Find Global Maximum
console.log(Math.max(...list));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment