GithubHelp home page GithubHelp logo

Comments (1)

halfrost avatar halfrost commented on May 13, 2024

@hitzhangjie 这道题的真正意图并不是合并 2 个有序数组,切分以后的 4 部分能不能构成有序数组可以不关心。(当然实际情况是这 4 部分一定可以构成有序数组,有 2 个指针分别指向这两个有序数组,每次合并的时候判断这两个指针指的元素大小,据此作为合并的规则)如果这道题按照合并有序数组去做,时间复杂度是 O(m+n),把两者合并成一个有序数组,然后取出中位数即可。但是这样做时间复杂度高了,原因是多做了一些“工作”,此题只要求找到中位数,其他的元素是否有序并不关心。所以我画图的时候故意想弱化具体数值的概念,重点关注在二分切分点左右两个元素的大小关系上。

from leetcode-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.