SHARE
TWEET

Untitled

a guest Apr 25th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Solution {
  2.     public double FindMedianSortedArrays(int[] nums1, int[] nums2) {
  3.             int[] newArr = new int[nums1.Length + nums2.Length];
  4.             nums1.CopyTo(newArr, 0);
  5.             nums2.CopyTo(newArr, nums1.Length);
  6.             newArr = newArr.OrderBy(x => x).ToArray();
  7.             if (newArr.Length % 2 == 0)
  8.             {
  9.                 int index1 = newArr.Length / 2;
  10.                 return (double)(newArr[index1-1] + newArr[index1]) / 2;
  11.             }
  12.             else
  13.             {
  14.                 int index = (int)Math.Floor((double)newArr.Length / 2);
  15.                 return newArr[index];
  16.             }
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top