Giter Club home page Giter Club logo

Comments (4)

xiaoyuzdy avatar xiaoyuzdy commented on August 23, 2024

按你的思路写了一段代码,感觉比较次数并没有减少多少,而且非常的麻烦,要考虑上坡,下坡,还有中间值大于两边的情况,还有一边扫描完继续扫描另一边要防止进入死循环的情况,你看一下吧,我写的感觉很臃肿你可以优化一下https://github.com/xiaoyuzdy/Algorithms/blob/master/AlgorithmsTest/src/Num1_1_04/Num_1_04_18.java
我看了你写的这题是有问题的,比如int a[]={1,2,3,4,5,0,1};在不打乱顺序的情况你试一下会报异常的

from algorithms.

BeccaLiu avatar BeccaLiu commented on August 23, 2024

我覺得題意應該是默認array中有多個minima吧,所以我用了個random後的大數組,就是默認上升坡度的左邊一定有個min,或下降破的右邊有個min,想的比較簡單。你給的數組,反而會報錯,之前我也是沒想到。不過我這樣只搜一次是lgn,而題目說最差2lgn,所以我覺得答案應該是要兩次binary search,不過我也還沒想到

from algorithms.

xiaoyuzdy avatar xiaoyuzdy commented on August 23, 2024

不知道你看得是英文原版还是中文版的,我看的中文版这题的题意就比较模糊,没说数组中的数据有某种规律,而对于一般的乱序数组我觉得是达不到2lgn的(我想不到有什么办法可达实现这样的目标)

from algorithms.

BeccaLiu avatar BeccaLiu commented on August 23, 2024

嗯,即使是英文版,也蠻多題目題意模糊的,比如1.4.23

from algorithms.

Related Issues (6)

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.