I add the supplemental for my Phone.com interview since GlassDoor disallows names, URLs and other useful bits.
They used this CoderPad:
const _ = require('lodash');
function sayHello() {
console.log('Hello, World');
}
_.times(5, sayHello);
/*
Your previous Python 3 content is preserved below:
def two_sum(numbers: List[int], target_sum: int) -> Tuple[int, int]:
"""Given an array of integers, return indices of the two numbers such
that they add up to a specific target.
You may assume that number will always contain a pair that sums to target_sum.
"""
pass
assert two_sum([3, 5, -2, 7, -10], 1) == (0, 2)
assert two_sum([3, 5, -2, 7, -10], 12) == (1, 3)
*/
function two_sum(list, target) {
let tuples = []
let answer = 0
//get all tuples
//for not forEach
list.forEach((a, i) => {
if(i<list.length-1) {
list.forEach((a2, i2) => {
if(i2<list.length-1) {
console.log(a,a2)
if(a+a2==target)
answer = {index1 : i,index2: i2}
}
})
}
})
return answer
}
let answer = two_sum([3, 5, -2, 7, -10], 12)
console.log(answer)