Created
March 2, 2021 20:12
-
-
Save KakoozaJerry/35c4eab87a42397a612395a556237d50 to your computer and use it in GitHub Desktop.
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
/** | |
* @param {number[]} nums1 | |
* @param {number[]} nums2 | |
* @return {number} | |
*/ | |
let totals = (garray) => { | |
let count = 0; | |
for (let i=0; i < garray.length; i++){ | |
let result = garray[i]; | |
count =result + count; | |
} | |
return count; | |
} | |
var findMedianSortedArrays = function(nums1, nums2) { | |
let numnew = nums1.concat(nums2); | |
numnew.sort((a,b) => a - b) | |
let values = 0; | |
let checksum = Math.floor(numnew.length/2) | |
if (numnew.length%2!=0){ | |
values = numnew[checksum] | |
}else { | |
values = (numnew[checksum]+numnew[checksum-1])/2 | |
} | |
let score = totals(numnew)/(nums1.length+nums2.length); | |
console.log(values) | |
return values | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment