Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
42fe56a
solve issue #58 find guestlist for Max fun
yjlim5 Jun 5, 2017
061c1c5
Test & Solution for #34
Jun 5, 2017
9875e4a
Necessary Changes
Jun 5, 2017
89f778d
Modified test file for #34
Jun 6, 2017
8f7b429
Deleted 34a.js solutions file
Jun 6, 2017
2ee704f
Modified test file for #34 again.
Jun 7, 2017
e9f6b25
solution and test for #32
rkalra247 Jun 7, 2017
ee0b8c2
solution and test for problem #21
rkalra247 Jun 8, 2017
6e11848
Test & Solution for #61
Jun 5, 2017
c314233
Modified test file for #61
Jun 6, 2017
5c59678
Modified test file for #61 again
Jun 7, 2017
5684ed9
Corrected solution for #61.
Jun 8, 2017
746e72a
Merge branch 'master' into mc5
seemcat Jun 12, 2017
1f5e2ae
Merge branch 'master' into mc6
seemcat Jun 12, 2017
6c473d5
Merge pull request #88 from rkalra247/problem32
dsope05 Jun 13, 2017
e883ddf
Merge pull request #90 from rkalra247/probelm21
dsope05 Jun 13, 2017
8ddd9e6
Merge pull request #71 from seemcat/mc5
dsope05 Jun 13, 2017
06eaffd
Merge pull request #72 from seemcat/mc6
dsope05 Jun 13, 2017
407ea09
issue #58 move Employee class to solution file and use reduce functions
yjlim5 Jun 14, 2017
c6e25ef
remove unnecessary newline
yjlim5 Jun 14, 2017
8c2970f
Merge pull request #75 from yjlim5/yj2
yjlim5 Jun 15, 2017
4d937c0
Test & Solution for #8
Jun 5, 2017
33f4991
Necessary Changes
Jun 5, 2017
d3c2b16
Modified test file for #8
Jun 7, 2017
f5a0be4
Test & Solution for #31.
Jun 9, 2017
78af455
Merge pull request #104 from seemcat/mc1
yjlim5 Jun 15, 2017
4b177b3
Merge pull request #99 from seemcat/mc9
yjlim5 Jun 15, 2017
404c0c0
another solution for problem #13
rkalra247 Jun 8, 2017
d74d539
updated solution
rkalra247 Jun 20, 2017
2d63633
deleted extra spaces #problem13
rkalra247 Jun 21, 2017
b20b514
solutions and test #15
ColinX13 Jun 21, 2017
2e3e914
Merge pull request #110 from rkalra247/problem13
yjlim5 Jun 21, 2017
3cc392a
Merge pull request #112 from ColinX13/colin15
yjlim5 Jun 21, 2017
442d752
fix test issues
yjlim5 Jul 4, 2017
5a8c6cb
Merge pull request #113 from yjlim5/yj3
yjlim5 Jul 4, 2017
500287e
remove obsolte yourSolution file
yjlim5 Jul 5, 2017
5af7d9f
fix the test imports and improve template in yourSolution.js
yjlim5 Jul 5, 2017
96fcb01
Merge pull request #115 from yjlim5/yj4
yjlim5 Jul 5, 2017
100b5c1
Solution to issue #18 in Python (#26)
Himanshu1495 Jul 7, 2017
80bf94a
Solution and Test for issue #34 (#107)
Himanshu1495 Jul 7, 2017
d50a3f6
flatten array
dsope05 Aug 13, 2017
ef07689
min coin solution
dsope05 Aug 13, 2017
f18888f
fix comments
dsope05 Aug 14, 2017
7205898
fix comments
dsope05 Aug 14, 2017
eb9489e
Merge pull request #117 from dsope05/dan1
yjlim5 Aug 14, 2017
8009870
Merge pull request #118 from dsope05/dan3
dsope05 Aug 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions solutions/116.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// flatten the array
//
const solution = (arr) => {
if (arr.length === 0) {
return arr;
}
let elem = arr.shift();
if (elem.length) {
elem.forEach((elem) => {
arr.push(elem);
});
solution(arr);
} else {
solution(arr).push(elem);
}
return arr;
};

module.exports = {
solution: solution,
};
15 changes: 15 additions & 0 deletions solutions/13.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
//Rahul Kalra
//Checking to see if the string is palindrome
const solution2 = (palindromeInput) =>{
let reverse = "";
for(let i = palindromeInput.length - 1; i >= 0; i--){
reverse += palindromeInput[i];
}
if(reverse === palindromeInput){
return true;
}
return false;
};

// vdewinter
// Return true if input string is a palindrome

Expand All @@ -15,4 +28,6 @@ const solution = (str) => {

module.exports = {
solution,
solution2
};

12 changes: 12 additions & 0 deletions solutions/15.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ const solution = (fullString, subString) => {
return fullString.includes(subString);
};

// Colin Xie
const solution1 = (fullString, subString) => {
for(let i = 0; i < fullString.length; i++){
let subFull = fullString.substring(i,i + subString.length);
if(subFull === subString){
return true;
}
}
return false;
};

module.exports = {
solution,
solution1,
};
35 changes: 35 additions & 0 deletions solutions/21.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Rahul Kalra
// Return array of largest 3 values in descending order from a given array

const max = (array) =>{
let max = array[0];
for(let i = 0; i < array.length; i++){
if(max <= array[i+1]){
max = array[i+1];
}
}
return max;
};

const removeNum = (array, max) =>{
let newArray = [];
for(let i = 0; i < array.length; i++){
if(!(max === array[i])){
newArray.push(array[i]);
}
}
return newArray;
};

const solution = (array) =>{
let a = 0;
let newArray = [];
for(let i = 0; i < 3; i++){
a = max(array);;
array = removeNum(array, a);
newArray.push(a);
}
return [newArray[0], newArray[1], newArray[2]];
};

module.exports = {solution};
20 changes: 17 additions & 3 deletions solutions/31.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// input: ['hi','hello','hola']
// output 'hello'

// Solutions by Colin Xie @ColinX13

// Solution by Colin Xie @ColinX13
// Solution1 by Maricris Bonzo @Seemcat
/**
* @param {string[]} arr - the array of strings
* @return {string} word - the longest word in the array
*/
*/
const solution = (arr) => {
let maxLength = 0;
let word = 0;
Expand All @@ -20,6 +20,20 @@ const solution = (arr) => {
}
return word;
};

const solution1 = (arr) => {
let big = arr[0];
let i = 1;
while(i < arr.length){
if (big.length < arr[i].length){
big = arr[i];
}
i++;
};
return big;
};

module.exports = {
solution,
solution1
};
23 changes: 23 additions & 0 deletions solutions/32.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//Rahul Kalra
//Finding Singleton

const solution = (array) =>{
let data = {};
let newArray = [];
for(let i = 0; i < array.length; i++){
if(!(data[array[i]])){
data[array[i]] = 1;
}
else{
data[array[i]]++;
}
}
for(let key in data){
if(data[key] === 1){
newArray.push(Number(key));
}
}
return newArray;
};

module.exports = {solution};
26 changes: 22 additions & 4 deletions solutions/34.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Daniel
// Number of repeating elements in an array

const solution = (arr, k) => {
let total = 0;
for (i=0; i < arr.length; i++) {
Expand All @@ -9,7 +8,26 @@ const solution = (arr, k) => {
}
}
return total;
};
module.exports = {
solution,
};

// Maricris Bonzo
const solution1 = (array, num) => {
let i = 0;
let numOfTimes = 0;

while (i < array.length){
if (array[i] === num){
numOfTimes = numOfTimes + 1;
i++;
} else {
i++;
}
}
return numOfTimes;
};

module.exports = {
solution,
solution1
};

17 changes: 17 additions & 0 deletions solutions/56.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ const solution = (arr, total) => {
return acc;
}, total);
};
// return min number of coins
// daniel s.
const solution2 = (arr, value) => {
if (value === 0) {
return 0;
};
let currentMin = value;
arr.forEach((coin)=> {
let childCoins = 0;
if (value - coin > 0) {
childCoins = solution2(arr, value - coin);
}
currentMin = Math.min(currentMin, childCoins);
});
return currentMin + 1;
};

module.exports = {
solution,
solution2,
};
61 changes: 61 additions & 0 deletions solutions/58.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Max Fun Problem
// Return an array of employees that creates the maximum fun
// Input: Employee object
// Output: [Employee objects]

// Solution by Yoo Jin

class Employee {
constructor(funVal, staffArray=[]) {
this.funVal = funVal;
this.staff = [];
this.addStaff(staffArray);
}

addStaff(staffArray) {
staffArray.forEach((staff) => {
this.staff.push(staff);
});
}
}

/**
* Given an Employee, return an array of employees that creates the maximum fun.
* There is one condition: An Employee cannot be on the guestlist if his direct manager is going to the party.
* @param {Employee} emp - an Employee with fun value and a list of his staff
* @returns {Employee []]} list - Array of employees that creates the maximum fun
*/
const solution = (emp) => {
if(!emp) {
return [];
}

if(emp.staff.length === 0) {
return [emp];
}

let funStaffListWithoutEmp = [];
let funValWithoutEmp = emp.staff.reduce((funVal, staff) => {
let staffList = solution(staff);
funStaffListWithoutEmp = funStaffListWithoutEmp.concat(staffList);
return staffList.reduce((acc, emp) => (acc + emp.funVal), funVal);
}, 0);

let funValWithEmp = emp.funVal;
let funStaffListWithEmp = [emp];
emp.staff.forEach((staff) => {
funValWithEmp = staff.staff.reduce((funVal, staff) => {
let staffList = solution(staff);
funStaffListWithEmp = funStaffListWithEmp.concat(staffList);
return staffList.reduce((acc, emp) => (acc + emp.funVal), funVal);
}, funValWithEmp);
});

return funValWithoutEmp > funValWithEmp ?
funStaffListWithoutEmp : funStaffListWithEmp;
};

module.exports = {
Employee,
solution
};
50 changes: 46 additions & 4 deletions solutions/61.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Input: 16,24
// Output: 8

// Solutions by Colin Xie @ColinX13
// Solution #0 by Colin Xie @ColinX13
// Solution #1 by Maricris Bonzo @seemcat

/*
* Factor is determined when both remainders of num1 and num2
* are 0 when factor is divided from them.
/**
* Factor is determined when both remainders of num1 and num2 are 0 when factor is divided from them.
* @param num1 - the first number input
* @param num2 - the second number input
* @return {number} factor - the greatest common factor for num1 and num2
Expand All @@ -19,6 +19,48 @@ const solution = (num1, num2) => {
}
}
};

const solution1 = (num1, num2) => {
let num1Array = [];
let num2Array = [];
let i = 1;
let j = 1;

while (i <= num1) {
if (num1%i === 0){
num1Array.push(i);
i++;
} else {
i++;
}
};

while (j <= num2) {
if (num2%j === 0){
num2Array.push(j);
j++;
} else {
j++;
}
};

let k = 0;
let commonNumbers = [];

while (k < num2Array.length){
if (num1Array.indexOf(num2Array[k]) === -1){
k++;
} else {
commonNumbers.push(num2Array[k]);
k++;
};
};

let GCD = Math.max.apply(Math, commonNumbers);
return GCD;
};

module.exports = {
solution,
solution1
};
13 changes: 13 additions & 0 deletions solutions/8.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ const solution = (string) => {
return newString;
};

// Maricris Bonzo: seemcat

const solution1 = (string) => {
let indexLength = string.length - 1;
let reverseString = '';

for(i = 0; i <= indexLength; i++){
reverseString = string[i] + reverseString;
}
return reverseString;
};

module.exports = {
solution,
solution1
};
17 changes: 17 additions & 0 deletions solutions/sol18.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Himanshu Nachane (@Himanshu1495)
'''return missing number in an input array of consecutively increasing numbers.

i: [5,6,8,9]
o: 7
'''

def missing_num(arr):
first_element = arr[0]
last_element = arr[-1]
new_sum = 0
for x in range(first_element,last_element+1):
new_sum += x
return new_sum - sum(arr)



Loading