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 Person{ | |
constructor(name){ | |
this.name = name; | |
} | |
//class method to return the string | |
toString(){ | |
return (`Name of person: ${this.name}`); | |
} | |
} | |
class Employee extends Person{ |
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 Movie = function(n, d) { | |
// private variables | |
let name = n; | |
let director = d; | |
// class method | |
this.giveName = function() { | |
return name; | |
} | |
// private method |
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 Movie = function(n, d){ | |
let name = n | |
let director = d | |
return { | |
description: function(){ | |
console.log(`${director} directed ${name} `) | |
} |
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 Movie { | |
//initialize the instance of Move class with name and director | |
constructor(name, director){ | |
this.name = name | |
this.director = director | |
} | |
} |
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 maxSubArray = (nums) => { | |
// initiate two variable, maxSum for total max, sum for current max | |
let maxSum = -Infinity | |
let currentSum = 0 | |
// iterate through the nums, store sub-problems result | |
for(let i = 0; i < nums.length; i++){ | |
//cumulating answers to the top | |
//compare currentSum add current number | |
//with current number and store the maximum value |
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 Node { | |
constructor(value){ | |
this.value = value | |
this.next = null | |
} | |
} | |
class Queue { | |
constructor(){ |
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 Node { | |
constructor(value){ | |
this.value = value | |
this.next = null | |
} | |
} | |
class Queue { | |
constructor(){ |
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 RecentCounter{ | |
//initialize the class with queue property, | |
//which is an empty array | |
constructor(){ | |
this.queue = [] | |
} | |
//ping method receive integer t | |
//which represents some time in milliseconds | |
ping(t){ |
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 Node { | |
constructor(value){ | |
this.value = value | |
this.next = null | |
} | |
} | |
class Queue { | |
constructor(){ |
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 Node { | |
constructor(value){ | |
this.value = value | |
this.next = null | |
} | |
} | |
class Stack { |