Skip to content

Instantly share code, notes, and snippets.

View junjunparkpark's full-sized avatar

Jun Park junjunparkpark

  • San Francisco, CA
View GitHub Profile
@junjunparkpark
junjunparkpark / InterviewPrep.md
Last active October 12, 2019 16:47
Software Engineering Interview Prep
// 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);
@junjunparkpark
junjunparkpark / path-to-target-sum.js
Created June 22, 2017 16:30
Path to Target Sum - Interview Prompt HRSF78
/*
** Assuming that the tree is instantiated with the following: **
class Tree {
constructor(value) {
this.value = value;
this.children = [];
}
addChild(value) {
@junjunparkpark
junjunparkpark / classamount-class.js
Created June 15, 2017 17:04
Class Amount Class Interview Prompt
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];