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

开发一个网站能赚多少钱宝安中心区规划

开发一个网站能赚多少钱,宝安中心区规划,网页设计如何在图片上添加文字,代运营主要做什么题目描述 以数组 intervals 表示若干个区间的集合#xff0c;其中单个区间为 intervals[i] [start_i, end_i] 。请你合并所有重叠的区间#xff0c;并返回 一个不重叠的区间数组#xff0c;该数组需恰好覆盖输入中的所有区间 。 示例 1#xff1a; 输入#xff1a;int…题目描述 以数组 intervals 表示若干个区间的集合其中单个区间为 intervals[i] [start_i, end_i] 。请你合并所有重叠的区间并返回 一个不重叠的区间数组该数组需恰好覆盖输入中的所有区间 。 示例 1 输入intervals [[1,3],[2,6],[8,10],[15,18]] 输出[[1,6],[8,10],[15,18]] 解释区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. 示例 2 输入intervals [[1,4],[4,5]] 输出[[1,5]] 解释区间 [1,4] 和 [4,5] 可被视为重叠区间。 提示 1 intervals.length 10^4 intervals[i].length 2 0 start_i end_i 10^4 题解排序 思路 如果我们按照区间的左端点排序那么在排完序的列表中可以合并的区间一定是连续的。如下图所示标记为蓝色、黄色和绿色的区间分别可以合并成一个大区间它们在排完序的列表中是连续的 算法 我们用数组 merged 存储最终的答案。 首先我们将列表中的区间按照左端点升序排序。然后我们将第一个区间加入 merged 数组中并按顺序依次考虑之后的每个区间 如果当前区间的左端点在数组 merged 中最后一个区间的右端点之后那么它们不会重合我们可以直接将这个区间加入数组 merged 的末尾 否则它们重合我们需要用当前区间的右端点更新数组 merged 中最后一个区间的右端点将其置为二者的较大值。 代码 /*** Return an array of arrays of size *returnSize.* The sizes of the arrays are returned as *returnColumnSizes array.* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().*/// Function to compare intervals for sorting int compareIntervals(const void* a, const void* b) {int **arr1 (int **)a;int **arr2 (int **)b;// In this line, the function compares the start values of two intervals. // It accesses the first element of the arrays pointed to by arr1 and arr2 , // which corresponds to the start value of the intervals. // By subtracting the start value of the second interval from the start value of the first interval, // the function determines the order in which the intervals should be sorted. return arr1[0][0] - arr2[0][0]; }// Function to merge overlapping intervals int** merge(int** intervals, int intervalsSize, int* intervalsColSize, int* returnSize, int** returnColumnSizes) {// Check if the input array is emptyif (intervalsSize 0) {*returnSize 0;return NULL;}// Sort intervals based on the start valueqsort(intervals, intervalsSize, sizeof(int*), compareIntervals);// Initialize variables for merged intervalsint** merged (int**)malloc(intervalsSize * sizeof(int*));*returnColumnSizes (int*)malloc(intervalsSize * sizeof(int));int mergedCount 0;// Iterate through the sorted intervals to merge overlapping intervalsfor (int i 0; i intervalsSize; i) {int L intervals[i][0], R intervals[i][1];// If the merged array is empty or the current interval does not overlap with the last interval in mergedif (mergedCount 0 || merged[mergedCount - 1][1] L) {// Add the current interval to the merged arraymerged[mergedCount] (int*)malloc(2 * sizeof(int));merged[mergedCount][0] L;merged[mergedCount][1] R;(*returnColumnSizes)[mergedCount] 2;mergedCount;} else {// Update the end of the last interval in merged if there is an overlapmerged[mergedCount - 1][1] (R merged[mergedCount - 1][1]) ? R : merged[mergedCount - 1][1];}}*returnSize mergedCount; // Set the size of the merged arrayreturn merged; // Return the merged intervals }
http://www.zqtcl.cn/news/28221/

相关文章:

  • 遵义网站建设哪家强wordpress 国内 优化
  • 视频网站做游戏分发合肥网站建设推荐 晨飞网络
  • 北京南站地铁线路图wordpress添加网址为导航
  • 买完域名以后怎么做网站微信推广方案
  • 网站域名注册多少钱wordpress心得
  • 数据库网站建设公司毕业设计网站开发的中期报告
  • 株洲seo网站优化软件十堰网站建设
  • 建立网站程序中国电信网站备案 锁定
  • 阿里云域名空间网站建设东莞全网seo排名优化中心
  • 网站备案接入服务单位电子商务网站建设的体会
  • 旅游网站系统wordpress开发app订制软件
  • 天津网站快速排名提升长沙公司排名
  • 惠州建设局网站附近网站建设公司
  • 佛山专业外贸网站建设linux目录不可写 wordpress
  • 软文范例大全200字网站seo优化培训
  • 绍兴手机网站制作东道设计官网
  • 周口哪里做网站在哪查询网站做的哪些外链
  • php网站开发培训学校重庆模板网站建站
  • 天津网站备案时间app企业网站
  • 网站固定通栏代码商城类型的网站怎么做
  • 如何使用天翼云主机建设网站怎么做私人彩票网站
  • 网站备案幕布拍照是什么建设银行官方网站下载
  • 用什么网站做海报 知乎新电商网站
  • 网站建设 整改报告个人作品主页wordpress
  • 网站文化制度建设齐博cms
  • 网站服务器权限恩平国有建设用地使用权拍卖网站
  • 网站建设音乐插件怎么弄云seo
  • 网站建设销售开场白徐州沛县网站建设
  • 怎样通过网址浏览自己做的网站wordpress 入侵视频
  • 北京做网站商标的公司百度app常用网址在哪里