Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Dec 10, 2023
1 parent 35a5d33 commit 78c934a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions coding_interviews/algoexpert/class-photos/class-photos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function classPhotos(redShirtHeights, blueShirtHeights) {
redShirtHeights.sort((a, b) => a - b);
blueShirtHeights.sort((a, b) => a - b);

let backRow;
let frontRow;

if (redShirtHeights[0] < blueShirtHeights[0]) {
backRow = blueShirtHeights;
frontRow = redShirtHeights;
} else {
backRow = redShirtHeights;
frontRow = blueShirtHeights;
}

for (let index = 0; index < backRow.length; index++) {
if (frontRow[index] >= backRow[index]) return false;
}

return true;
}

0 comments on commit 78c934a

Please sign in to comment.