Frage im Vorstellungsgespräch bei EverQuote

How to search a 2D array for an integer.

Antworten zu Vorstellungsgespräch

Anonym

9. Nov. 2019

Updated Javascript solution: var searchMatrix = function(matrix, target) { let found = false; matrix.forEach((element) => { element.forEach((subElement) => { if (subElement === target) { found = true; } }); }); return found; };

1

Anonym

9. Nov. 2019

Javascript Solution: let found = false; array.forEach((element) => { if (element === desired) { found = true; } } return found;

Anonym

9. Nov. 2019

Sorry my answer above is incorrect - I thought this was for a single dimension array - disregard please.