This file contains 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 inputMatrix = [ | |
[1, 1, 4, 1], | |
[4, 3, 3, 6], | |
[5, 3, 4, 6], | |
[9, 3, 5, 5], | |
]; | |
const outputMatrix = [ | |
[9, 5, 4, 1], | |
[3, 3, 3, 1], | |
[5, 4, 3, 4], |
This file contains 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
//https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ | |
// in progress, almost there! | |
/** | |
* @param {number[]} prices | |
* @return {number} | |
*/ | |
var maxProfit = function(prices) { | |
let currentBest = 0; | |
//let pricesCopy = [...prices] |
This file contains 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
// The global variable | |
const watchList = [ | |
{ | |
"Title": "Inception", | |
"Year": "2010", | |
"Rated": "PG-13", | |
"Released": "16 Jul 2010", | |
"Runtime": "148 min", | |
"Genre": "Action, Adventure, Crime", | |
"Director": "Christopher Nolan", |
This file contains 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
// this is a basic for loop, uses modulus operator, prints 0 to 100 for even | |
// numbers | |
for (let i = 0; i < 100; i++){ | |
if (i % 2 == 1){ | |
console.log(i); | |
} | |
else { | |
} | |
} |
This file contains 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
// https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-3-largest-prime-factor | |
//a prime is only divisible by 1 and itself | |
// we need a loop, with an if divisible | |
//in a loop test for all factors of given number | |
//then we need to test those for primeness | |
function largestPrimeFactor(number) { |
This file contains 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
//https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-2-even-fibonacci-numbers | |
function fiboEvenSum(n) { | |
// write a fibo sequence generator | |
let fiboArr = [1,2] | |
for(let i=0; i < n; i++){ | |
fiboArr.push(fiboArr[i] + fiboArr[i+1]) | |
} | |
console.log(fiboArr) |
This file contains 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
// Problem 9: Special Pythagorean triplet | |
// https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-9-special-pythagorean-triplet | |
function specialPythagoreanTriplet(n) { | |
let sumOfabc = n; | |
/* | |
a b c | |
1 2 3 | |
2 3 4 |
This file contains 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
//regular function example with a return | |
function addition(number){ | |
return number + 100; | |
} | |
console.log(addition(66)) | |
//arrow function example | |
const additionV2 = number => number + 100; | |
console.log(additionV2(66)) |
This file contains 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
// League is a Class | |
// WNBA, NBA, NFL, NHL, MLB, would be objects of this class | |
// Sport Type, Name of the League, Country, Gender | |
//class definition | |
class League { | |
constructor(leagueName){ | |
this.leagueName = leagueName; | |
this.teams = []; |
This file contains 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 House { | |
constructor(name) { | |
this.name = name; | |
this.rooms = []; | |
} | |
addRoom(name, area) { | |
this.rooms.push(new Room(name, area)); | |
} | |
} |