Software Engineering Interview Prep
High Level Roadmap:
-
Princeton Coursera course on algorithms
- Up until Dijkstra’s algorithm
-
- For general algorithms and data structures background
Software Engineering Interview Prep
High Level Roadmap:
Princeton Coursera course on algorithms
// Inputs: Array of 1 character strings | |
// Outputs: The same array of character strings with all the vowels 'doubled' | |
// Constraints: Do not manipulate strings nor create data structures or a new array. | |
// Edge cases: None | |
// Pseudocode implementation: | |
// Create an object that one can compare each character in the array to, indicating whether a char is a vowel. | |
// For each index in the array, starting at the 0 index up to arr.length - 1 | |
// Create a current character variable that will represent the string at a given index in the array | |
// If the char is a vowel |
var productExceptSelf = function(nums) { | |
let results = []; | |
nums.forEach((num, i) => { | |
let product = nums.reduce((acc, val, j) => i === j ? acc : acc *= val ); | |
results.push(product); | |
}) | |
return results; | |
}; |
var kthSmallest = function(root, k) { | |
let record = []; | |
var traverseTree = function(node) { | |
record.push(node.val); | |
if (node.left) { return traverseTree(node.left) } | |
if (node.right) { return traverseTree(node.right) } | |
} | |
traverseTree(root); |
/* | |
** Assuming that the tree is instantiated with the following: ** | |
class Tree { | |
constructor(value) { | |
this.value = value; | |
this.children = []; | |
} | |
addChild(value) { |
class CashAmount { | |
constructor(amount) { | |
this.amount = JSON.stringify(amount); | |
} | |
totalInPennies() { | |
var total = ''; | |
this.amount.toString().split('').forEach(digit => { if (digit !== '.') { total += digit;} }) | |
return total; | |
} |
var generate = function(numRows) { | |
if (numRows === 0) { return []; } | |
var pascalsTriangle = [[1]]; | |
for (let i = 1; i < numRows; i++) { | |
var last = pascalsTriangle[pascalsTriangle.length - 1]; | |
var newLevel = []; | |
for (let j = 0; j <= last.length; j++) { | |
var previous = last[j - 1]; |