Giter Club home page Giter Club logo

Comments (3)

orangewangjie avatar orangewangjie commented on June 22, 2024

比如{1,1,2,2,5,6,7,8,9} 本来的代码应该就找不出答案

from codinginterviewchinese2.

JiaoZK avatar JiaoZK commented on June 22, 2024

{2,2,3,3,5,5,6,6} 这种肯定找不到

from codinginterviewchinese2.

1234cas avatar 1234cas commented on June 22, 2024

[0, 0, 1, 2, 4, 5, 6, 7, 8, 9],这样的样例从第一次二分的时候,就发现不了正确的重复区间了,因为第一次遍历时候,发现[0, 4]范围内是5个数字,所以认为重复出现在[5, 9],所以出现了错误。想问一下这个要如何解决? 我想到一种方法:对[0, 4]找到的该区间的数字进行求和,如果出现了5:5的情况,且求和的值也符合预期,那么才可能会出现在后半部分(反例,[0, 0, 3, 3, 4], 5:5, 且求和的值也还是10= [0, 4]的总和)

该题题目是在n+1长度的数组中的数组在1~n范围内。所以这个本就不符合题意

该题题解无法解决0重复出现应该是因为在
if (count > (mid - start + 1)) end = mid
如果start为0 会导致count = mid
无法正确二分

from codinginterviewchinese2.

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.