当前位置: 首页 > news >正文

南昌做网站设计自助建设网站

南昌做网站设计,自助建设网站,在wordpress中设置mx记录,黑龙江网站建设巨耀网络题目 寻找两个正序数组的中位数 给定两个大小分别为 m 和 n 的正序#xff08;从小到大#xff09;数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。 算法的时间复杂度应该为 O(log (mn)) 。 示例 1#xff1a; 输入#xff1a;nums1 [1,3], nums2 [2] 输…题目 寻找两个正序数组的中位数 给定两个大小分别为 m 和 n 的正序从小到大数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。 算法的时间复杂度应该为 O(log (mn)) 。 示例 1 输入nums1 [1,3], nums2 [2] 输出2.00000 解释合并数组 [1,2,3] 中位数 2 示例 2 输入nums1 [1,2], nums2 [3,4] 输出2.50000 解释合并数组 [1,2,3,4] 中位数 (2 3) / 2 2.5 2023年3月13号的解法 class Solution { public: double findMedianSortedArrays(vector nums1, vector nums2) { const int Len nums1.size() nums2.size(); const int iAvg1 Rec(nums1.data(), nums1.data() nums1.size(), nums2.data(), nums2.data() nums2.size(), (Len - 1) / 2); if (Len 1) { return iAvg1; } const int iAvg2 Rec(nums1.data(), nums1.data() nums1.size(), nums2.data(), nums2.data() nums2.size(), (Len - 1) / 21); return (iAvg1 iAvg2) / 2.0; } int Rec(int* b1, int* e1, int* b2, int* e2, int iFindIndex) { if (b1 e1) { return b2[iFindIndex]; } if (b2 e2) { return b1[iFindIndex]; } if (0 iFindIndex) { return min(*b1, *b2); } int k (iFindIndex 1) / 2; const int index1 min(k - 1,(int)( e1 - b1)-1); const int index2 min(k - 1, (int)(e2 - b2 )- 1); if (b1[index1] b2[index2]) { return Rec(b1 index1 1, e1, b2, e2, iFindIndex - index1 - 1); } return Rec(b1, e1, b2 index2 1, e2, iFindIndex - index2 - 1); } }; 2023年8月6号的解法 class Solution { public: double findMedianSortedArrays(vector nums1, vector nums2) { m_c nums1.size() nums2.size(); m_iHalf m_c / 2; int left 0, r min(m_iHalf, (int)nums1.size()) 1;//左闭右开 while (r left 1) { const auto mid left (r - left) / 2; const int leftLen2 m_iHalf - mid; const int iRet Cmp(mid, leftLen2, nums1, nums2); if (0 iRet) { break; } else if (iRet 0) { r mid; } else { left mid; } } if (m_dRet 0 ) { Cmp(left,m_iHalf-left,nums1,nums2); } return m_dRet; } int Cmp(int leftLen1, int leftLen2, const vector nums1, const vector nums2) { if (leftLen2 nums2.size()) { return 1; } int iLeftMax INT_MIN; if (leftLen1 0) { iLeftMax max(iLeftMax, nums1[leftLen1 - 1]); } if (leftLen2 0) { iLeftMax max(iLeftMax, nums2[leftLen2 - 1]); } int iRightMin INT_MAX; if (leftLen1 nums1.size()) { iRightMin min(iRightMin, nums1[leftLen1]); } if (leftLen2 nums2.size()) { iRightMin min(iRightMin, nums2[leftLen2]); } if (iLeftMax iRightMin) { if (1 m_c) { m_dRet iRightMin; } else { m_dRet (iLeftMax iRightMin) / 2.0; } return 0; } if ((leftLen1 0) (nums1[leftLen1 - 1] iRightMin)) { return-1; } return 1; } double m_dRet-1; int m_c; int m_iHalf; }; 其它 视频课程 如果你觉得复杂想从简单的算法开始可以学习我的视频课程。 https://edu.csdn.net/course/detail/38771 我的其它课程 https://edu.csdn.net/lecturer/6176 测试环境 win7 VS2019 C17 相关下载 doc版文档排版好 https://download.csdn.net/download/he_zhidan/88348653
http://www.hkea.cn/news/14480094/

相关文章:

  • 公司建立自己的网站吗保山专业的网站建设
  • 网站设计实验保险网站建设方案
  • 兼职做平面模特网站服装市场调网站建设的目的
  • 没公司怎么做网站手机网站建设wap
  • 设计网站免费素材企业大型网站建设要多少钱
  • 辽阳高端网站建设公司创业网站建设
  • centos做网站服务器吗深圳建设工程交易中心宝安中心
  • 简述网站建设流程中的各个步骤银徽seo
  • 江苏省建设工程交易中心网站微信公众号开通流程
  • php怎么做网站教程flash网页制作
  • 安卓系统上怎样做网站前端开发dsicuz做的网站
  • 阿里云备案多个网站吗阜阳市住房和城乡建设部网站
  • 格尔木市住房和城乡建设局网站wordpress 后台速度慢
  • 做网站 看什么书北京云无限优化
  • 律师做网站推广有用吗建设网站财务分析
  • 我要找人做网站的主页微信app官网下载
  • 利用虚拟主机建设网站的实验报告企业网站html
  • 北京seo公司网站建设网站用户名是什么意思
  • 购物优惠券网站怎么做福建省建设厅考试网站
  • 古楼角网站建设node.js下载wordpress
  • 成都百度网站制作六安住房和城乡建设部网站
  • 怎么样让网站正常解析计算机网站开发背景
  • 企业建站系统下载福建建设监理网站
  • 浙江省建设注册管理中心网站首页wordpress 插件推荐
  • 呼和浩特网站制作公司一级a行做爰片免费网站
  • 西安网站建设外包服务计算机软件开发培训
  • 常州外贸网站建设公司职业技术学院网站建设项目
  • 帮别人做网站开票开什么税目做会员体系的网站
  • vs2017手机网站开发淘宝券商城网站制作
  • 成都网站建设公司有哪几家口碑营销的前提及好处有哪些?