Easy C# Code in O(log(m+n))

  • -1
    public class Solution {
        public double FindMedianSortedArrays(int[] nums1, int[] nums2) {
            // Convert to List and Sort them
            List<int> List = nums1.ToList();
            // return value depends on even or odd
            if(List.Count == 0)  // no answer actually
                return 0;
            else if(List.Count%2 == 0)
                return ((double)List[List.Count/2-1] + (double)List[List.Count/2]) / 2;
                return (double)List[List.Count/2];

  • 0

    I've seen many people post such non-O(log(m+n)) code before, but I'm not sure I've ever seen one of them claim O(log(m+n))...

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.