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

滑县住房和城乡建设局网站南昌做网站设计

滑县住房和城乡建设局网站,南昌做网站设计,中国网站建设服务中心,怎么做淘宝网站的网页设计题目 寻找两个正序数组的中位数 给定两个大小分别为 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/14355075/

相关文章:

  • 滨江道网站建设中国做外贸网站有哪些
  • 平台网站建设ppt模板广告网站推广销售
  • 网站推广分销系统什么网站做贸易好
  • 网站科普信息化建设的意义网站建设怎么样工作室
  • 注册城乡规划师报名wordpress显示标题和seo标题
  • 伊宁网站建设优化网站流量超了
  • 杭州网站设计予尚网站建设参数
  • 一级a做爰片拍网站什么是网络营销含义
  • 襄阳城乡建设局网站首页网站推广免费渠道
  • 上海网站开发建设价格廊坊哪里做网站
  • 建网站开发语言对比苏州集团网站建设
  • 楼盘网站开发报价公众号可以做自己网站的超链接
  • 长沙建站宝网络科技有限公司网站建设丨下拉找金手指上词快
  • 常州网站定制消耗品分类
  • 福永镇网站建设网站关键词推广做自然排名
  • 网站是如何做的好wordpress加腾讯云cdn
  • 网站建设大作业电子版桂林公司做网站
  • 福建省住房和城乡建设厅门户网站如何把网站做的更好
  • 海宁网站网站建设手机版网站怎么上传
  • 东莞微联建站徐州英文网站seo
  • 室内设计学校网站惠州seo排名
  • 创建网站大约多少钱2018怎样做外贸网站
  • 为什么公司网站打不开最专业的营销网站建设
  • 网站怎么快速被百度收录WordPress和微信公众号
  • iis配置网站访问权限建设企业网站就等于开展网络营销
  • 提供网站建设工具的品牌有哪些页面设计线稿
  • 网站品质有服务器自己怎么做网站
  • 游戏开发比网站开发微博营销网站
  • 陕西网站建设报价wordpress格式刷
  • 网站开发访客ip高明铝业网站建站