I hereby claim:
- I am dzoltok on github.
- I am davidzoltok (https://keybase.io/davidzoltok) on keybase.
- I have a public key ASB1FHFC4Y_RdUQUFzpW_mIGFpSfKa7fzpfGzhDqvotX8Qo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// input is an array of strings | |
// e.g. ['foo', 'bar', '3'] | |
function encode(input) { | |
var output = ""; | |
input.forEach(function(element) { | |
output += element.length + '.' + element; | |
}); | |
return output; | |
} | |
function sumPossible(arr, target) { | |
// Option 1, the naive and slow way, O(n^2) | |
for (var i = 0; i < arr.length; i ++) { | |
for (var j = i +1; j < arr.length; j ++) { | |
if (arr[i] + arr[j] === target) { | |
return true; | |
} | |
} | |
} |
/** | |
* Question | |
* | |
* Write a function that uses merge(list1, list2) to merge an array of lists into a single list | |
* | |
* Analysis | |
* | |
* O(nk), where k is the number of lists and n is the maximum length among the lists | |
*/ | |
function mergeAll(lists) { |
/** | |
* Question | |
* | |
* Write an algorithm that returns true if a given input has evenly-matched brackets, and false otherwise | |
* | |
* Analysis | |
* | |
* O(n) where n is the length of the pattern to match | |
*/ |
/** | |
* 'k' points closest to origin | |
* | |
* Question | |
* | |
* Given a set of integer (x,y) coordinates and an integer k, write a function which returns the k points closest to the origin, i.e. (0, 0). | |
* | |
* Assumptions | |
* | |
* A coordinate is an object with two properties, 'x' and 'y' |