Comments (3)
比如{1,1,2,2,5,6,7,8,9} 本来的代码应该就找不出答案
from codinginterviewchinese2.
{2,2,3,3,5,5,6,6} 这种肯定找不到
from codinginterviewchinese2.
[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)
- 面试题60 第二种解法是不是有问题啊,会int溢出
- Partition function has extremely bad performance for array with identical values
- 面试题14剪绳子动态规划 HOT 5
- 面试题三2 题解有问题 HOT 4
- #面试题37
- 面试题30 是否有必要总是将min(value, m_min.top())压入辅助栈中? HOT 1
- 面试68题答案错误
- 面试题17的本题扩展
- c
- 面试题54:二叉搜索树的第K大节点 HOT 1
- 第二版勘误
- Singleton
- 面试题19的题目有误? HOT 1
- pro
- 面试题10:斐波那契数列测试用例过不去 HOT 1
- 51题,数组中的逆序对
- List.cpp 头文件 #include "list.h" 有误
- How to build and run CommonParentInTree.cpp on macOS?
- Hu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codinginterviewchinese2.