Created
May 16, 2022 20:49
-
-
Save lumie31/383c464e8aca3f36086ca9e800d63ada to your computer and use it in GitHub Desktop.
Cassidy's Interview question of the week Solution
This file contains 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
function maximizedArray(arr1, arr2) { | |
let mergedArr = arr1.concat(arr2); | |
let uniqueValues = new Set(mergedArr); | |
let uniqueArr = [...uniqueValues]; | |
let sortedArr = uniqueArr.sort((a, b) => b - a); | |
let result = sortedArr.slice(0, arr1.length); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment