| 1 | function classPhotos(redShirtHeights, blueShirtHeights) { |
| 2 | redShirtHeights.sort((a, b) => a - b); |
| 3 | blueShirtHeights.sort((a, b) => a - b); |
| 4 | |
| 5 | const shirtColorInFirsRow = |
| 6 | redShirtHeights[0] < blueShirtHeights[0] ? "RED" : "BLUE"; |
| 7 | |
| 8 | for (let idx = 0; idx < redShirtHeights.length; idx++) { |
| 9 | const redShirtHeight = redShirtHeights[idx]; |
| 10 | const blueShirtHeight = blueShirtHeights[idx]; |
| 11 | |
| 12 | if (shirtColorInFirsRow === "RED") { |
| 13 | if (redShirtHeight >= blueShirtHeight) return false; |
| 14 | } else if (blueShirtHeight >= redShirtHeight) return false; |
| 15 | } |
| 16 | return true; |
| 17 | } |
| 18 | |
| 19 | module.exports = classPhotos; |