Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lumie31
Created May 16, 2022 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lumie31/383c464e8aca3f36086ca9e800d63ada to your computer and use it in GitHub Desktop.
Save lumie31/383c464e8aca3f36086ca9e800d63ada to your computer and use it in GitHub Desktop.
Cassidy's Interview question of the week Solution
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