Created
February 18, 2015 06:12
-
-
Save dested/9471dfd2e17a045845f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a function 'find' in javascript that takes two argumens: | |
// N: A 2D Array of numbers where each row and each column are sorted in ascending order. | |
// v: A number | |
// If v is present in N, then find should return the position of v in N | |
// otherwise find should return false. | |
// Notes: | |
// Your code should be readable and efficient. | |
// You may NOT use the Javascript indexOf function in your code. | |
// For more clarification on the problem, see the example inputs below. | |
function find(L, v) { | |
// Write code here. | |
} | |
// Example input: | |
var L = [[1, 2, 3], [14, 15, 16], [27, 28, 29]]; | |
console.log(find(L, 12)); // --> false | |
console.log(find(L, 30)); // --> false | |
console.log(find(L, 1)); // --> [0, 0] | |
console.log(find(L, 29)); // --> [2, 2] | |
console.log(find(L, 16)); // --> [1, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment