public class Solution
{
public double FindMedianSortedArrays(int[] nums1, int[] nums2)
{
var nums = nums1.Concat(nums2).OrderBy(x => x).ToArray();
var len = nums.Length;
if (len % == )
{
return Convert.ToDouble(nums[len / ] + nums[len / - ]) / ;
}
else
{
return Convert.ToDouble(nums[len / ]);
}
}
}

leetcode4的更多相关文章

  1. leetcode-4. 寻找两个正序数组的中位数

    leetcode-4. 寻找两个正序数组的中位数. 给定两个大小为 m 和 n 的正序(从小到大)数组 nums1 和 nums2. 请你找出这两个正序数组的中位数,并且要求算法的时间复杂度为 O(l ...

  2. Leetcode4:Median of Two Sorted Arrays@Python

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  3. LeetCode4:Add Two Numbers

    题目: You are given two linked lists representing two non-negative numbers. The digits are stored in r ...

  4. LeetCode4 Median of Two Sorted Arrays

    题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...

  5. leetcode4 Valid Palindrome回文数

    Valid Palindrome回文数 whowhoha@outlook.com Question: Given a string, determine if it is a palindrome, ...

  6. LeetCode4. Median of Two Sorted Arrays---vector实现O(log(m+n)--- findkth

    这道题目和PAT上的1029是同一题.但是PAT1029用O(m+n)的时间复杂度(题解)就可以,这道题要求是O(log(m+n)). 这道题花费了我一个工作日的时间来思考.因为是log因而一直思考如 ...

  7. LeetCode-4. 两个排序数组的中位数(详解)

    链接:https://leetcode-cn.com/problems/median-of-two-sorted-arrays/description/ 有两个大小为 m 和 n 的排序数组 nums ...

  8. [Swift]LeetCode4. 两个排序数组的中位数 | Median of Two Sorted Arrays

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  9. leetcode4:两个排序数组的中位数

    给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 . 请找出这两个有序数组的中位数.要求算法的时间复杂度为 O(log (m+n)) . 1.我的思路:直接用sort,时间复杂度应如 ...

随机推荐

  1. Eclipse错误集合

    一.Could not write metadata for '/RemoteSystemsTempFiles'. 错误代码 Could not write metadata for '/Remote ...

  2. NotePad++配置使之支持jquery、html、css、javascript、php提示

    1.将以下文件复制到Notepad++\plugins\apis覆盖之前的xml文件 javascript.xml html.xml css.xml   2.打开notepad++设置>首选项& ...

  3. FCC JS基础算法题(3):Find the Longest Word in a String (找出最长单词)

    题目描述: 在句子中找出最长的单词,并返回它的长度.函数的返回值应该是一个数字. 基本思路,将字符串转换成数组,然后得出数组中单个元素的长度,对长度进行排序,返回最大的一个 代码: function ...

  4. windows2008 转 centos7 数据磁盘NTFS无损挂载

    转换时 原win硬盘里作为系统稳盘的硬盘必须重新格式化才能装机 数据盘在安装ntfs-3g可以直接挂载 几个重要命令: #lsblk  //查看硬盘情况 df -T 只可以查看已经挂载的分区和文件系统 ...

  5. laravel 常用命令

    1.创建控制器 php artisan make:controller ArticleController // 带 restful 风格 php artisan make:controller Ar ...

  6. linux下编译自己的库文件实践

    有了我传的那个资料,这个就没什么用了,那个太经典了,这个就是记录我自己的实践.:-) linux下文件的类型是不依赖于其后缀名的,但一般来讲:.o,是目标文件,相当于windows中的.obj文件.s ...

  7. 【leetcode】429. N-ary Tree Level Order Traversal

    problem 429. N-ary Tree Level Order Traversal solution1:Iteration /* // Definition for a Node. class ...

  8. select添加option

    本文介绍select添加option的两种方法 1.使用selectObject.add(option,before)方法,其中 option为要添加选项元素.必需是 option 或 optgrou ...

  9. Linux监控平台、安装zabbix、修改zabbix的admin密码

    1.Linux监控平台 2. zabbix监控 3.zabbix的安装下载:wget -c https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbi ...

  10. 在Linux中执行.sh脚本,异常

    在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...