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
function isMonotonic(arr: Number[]): Boolean { | |
let monoLeft = true; | |
let monoRight = true; | |
// loop thru the arr and check for the side by side items that makes the array non-monotonic | |
for (let i = 0; i < arr.length - 1; i++) { | |
// To check if | |
// array is not increasing | |
if (arr[i] > arr[i + 1]) { | |
monoLeft = false; |
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 mergeWord = (word1: string, word2: string) => { | |
let shorterWord = '' | |
let longerWord = '' | |
let accu = '' | |
if (word1.length < word2.length) { | |
shorterWord = word1 | |
longerWord = word2 | |
} else if (word2.length < word1.length) { | |
shorterWord = word2 | |
longerWord = word1 |
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
// Define core services | |
class TimeTravelService { | |
constructor( | |
private timelineAnalyzer: TimelineAnalyzer, | |
private dataVault: DataVault, | |
private encryptionService: EncryptionService, | |
private transporter: Transporter, | |
private auditor: Auditor | |
) {} |