given several intervals, how to find a interval which is a intersect of the most number of the given intervals?

Method:

Step1: Represent each returned interval in the following form [start, +1] , [end, -1]
Step2: You now have a list of tuples, the first element of which is a time. Sort these tuples by the time, irrespective of whatever is the second element. So you would have [t(i), val(i)], [t(i+1), val(i+1)], ... where val(i) = ±1. 
Step3: initialize two vars count = 0 and max =0
Step4: Now run through the sorted tuples and set count = count + val(i)
            Compare if count > max then 
                                set max = count
                                set answer = [t(i), t(i+1)]
Step5: Return answer

marzullo's algorithm的更多相关文章

  1. NTP Server

    Network Time Protocol互联网时间协议 NTP is intended to synchronize all participating computers to within a ...

  2. 挑子学习笔记:两步聚类算法(TwoStep Cluster Algorithm)——改进的BIRCH算法

    转载请标明出处:http://www.cnblogs.com/tiaozistudy/p/twostep_cluster_algorithm.html 两步聚类算法是在SPSS Modeler中使用的 ...

  3. PE Checksum Algorithm的较简实现

    这篇BLOG是我很早以前写的,因为现在搬移到CNBLOGS了,经过整理后重新发出来. 工作之前的几年一直都在搞计算机安全/病毒相关的东西(纯学习,不作恶),其中PE文件格式是必须知识.有些PE文件,比 ...

  4. [异常解决] windows用SSH和linux同步文件&linux开启SSH&ssh client 报 algorithm negotiation failed的解决方法之一

    1.安装.配置与启动 SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有 ...

  5. [Algorithm] 使用SimHash进行海量文本去重

    在之前的两篇博文分别介绍了常用的hash方法([Data Structure & Algorithm] Hash那点事儿)以及局部敏感hash算法([Algorithm] 局部敏感哈希算法(L ...

  6. Backtracking algorithm: rat in maze

    Sept. 10, 2015 Study again the back tracking algorithm using recursive solution, rat in maze, a clas ...

  7. [Algorithm & NLP] 文本深度表示模型——word2vec&doc2vec词向量模型

    深度学习掀开了机器学习的新篇章,目前深度学习应用于图像和语音已经产生了突破性的研究进展.深度学习一直被人们推崇为一种类似于人脑结构的人工智能算法,那为什么深度学习在语义分析领域仍然没有实质性的进展呢? ...

  8. [Algorithm] 群体智能优化算法之粒子群优化算法

    同进化算法(见博客<[Evolutionary Algorithm] 进化算法简介>,进化算法是受生物进化机制启发而产生的一系列算法)和人工神经网络算法(Neural Networks,简 ...

  9. [Evolutionary Algorithm] 进化算法简介

    进化算法,也被成为是演化算法(evolutionary algorithms,简称EAs),它不是一个具体的算法,而是一个“算法簇”.进化算法的产生的灵感借鉴了大自然中生物的进化操作,它一般包括基因编 ...

随机推荐

  1. 解题报告8VC Venture Cup 2017 - Elimination Round

    题目链接:http://codeforces.com/contest/755 本蒟蒻做了半天只会做前两道题.. A. PolandBall and Hypothesis 题意:给出n,让你找出一个m, ...

  2. cocos2d-3.x 创建动画

    1.多文件帧序列动画 TrademarkAnimation.h #ifndef __TRADEMARK_ANIMATION_H__ #define __TRADEMARK_ANIMATION_H__ ...

  3. zTree模糊查询人员姓名:getNodesByParamFuzzy

    以前使用zTree,不知道有getNodesByParamFuzzy这个模糊查询的方法,所以用了比较笨的方法,比如:功能要求(模糊查询人员姓名),先获得用户输入的名称,然后到数据库或者缓存中去查找,然 ...

  4. iis虚拟目录或应用程序不继承父站点的web.config配置信息

    A为主站点 B为A的应用程序站点 再A的web.config中对不想继承的节点用location 套起来.如下: <location path="." allowOverri ...

  5. Atitit 版本管理----分支管理

    Atitit 版本管理----分支管理 版本管理系统"(Version Control System Branch/tag在一个功能选项中,在使用中很容易产生混淆. 分支(Branch)管理 ...

  6. ACdream 1083 人民城管爱人民

    拓扑排序,然后从终点开始递推. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio ...

  7. js--事件对象的理解2

    实例1:一串跟着鼠标飞舞的div <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...

  8. input输入框只允许输入数字/ 数字+小数点/ 文字+字母/ 等解决方法

    1.只允许输入数字: <input type="text" onkeyup="this.value=this.value.replace(/[^0-9]/g,'') ...

  9. sql 多个字段排序,头一个字段排序完,再对第二个字段进行排序(以此类推)

    现根据num排序,num数字相同的根据时间进行排序,都是降序DESC SELECT * FROM counts ORDER BY num DESC,create_time DESC

  10. 浙江大学Pat 1036 题解

    1036. Boys vs Girls (25) This time you are asked to tell the difference between the lowest grade of ...