Implementing algorithms in the book of "Introduction to Algorithms" 3rd ed & various technical interview questions
All exercies are written in javascript
Copy to console in your browser or node filename.js to see the codes running
-
Chapter 2 : Insertion Sort & Merge Sort
-
Greedy Algorithm : a. getMaxProfit(stockArray) : find the max profit given an array containing stock price from the day before
b. getProductsOfAllIntsExceptAtIndex(intArray) : find the product of all numbers in the array except for the number at index
c. findMaxProduct(intArray) : find the maxProduct from 3 numbers in a given array
d. mergeTime(timeArray) : merge meeting time
-
Recursion : a. class fib : utilizing memoization to save recursive runs b. ascii_distance(str1, str2) : utilize Levenshtein Distance algorithm to find ascii code differences between two strings
-
Intersection: Finding Intersection between two rectangles
-
Temperarture Tracker : track temperature, utilize class method to track min, max, mean & mode
-
Binary Tree: a. superbalanced - difference between the depths of any two leaf nodes is no greater than one.
b. binary search tree - check if a binary tree is a valide binary search tree
c. find the 2nd largest element in a binary search tree.
d. binary search - find integer in a sorted array
e. binary search - find index of the rotating point in an array with words alphabetically sorted
-
Trie: a. Optimize space to store URLs.
-
Set: a. find two integers sum up to a number in an array of numbers
-
Memoization: a. fibonacci three ways!
-
Stack & Queue: a. optimize runtime for getMax() for a Stack b. construct a queue from two stacks c. finding closing parenthesis d. validate brackets/braces/parenthesis
-
Prime Number: a. testing isPrime for every number b. find prime number using Sieve of Eratosthenes
-
bit: a. find unique number or letter using bit wise calculation
-
Linked List: a. fastest way to delete a node in a singly linked list given only the node.
b. detect if a linked list has a cycle
c. reverse a linked-list in place
d. navigate to nth to the last node in a linked list