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 Dog { | |
public name: string; | |
constructor(name: string) { | |
this.name = name; | |
} | |
public makeSound(): void { | |
process.stdout.write('wuff wuff\n'); | |
} |
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 Animal { | |
public name: string; | |
constructor(name: string) { | |
this.name = name; | |
} | |
public makeSound(): void { | |
process.stdout.write('generic animal sound\n'); | |
} |
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 binarySearch(nums: number[], target: number): number { | |
let left: number = 0; | |
let right: number = nums.length - 1; | |
while (left <= right) { | |
const mid: number = Math.floor((left + right) / 2); | |
if (nums[mid] === target) return mid; | |
if (target < nums[mid]) right = mid - 1; | |
else left = mid + 1; |