zwkcoding / 100Days-Of-Leetcode

就像电影(500)Days of Summer一样,记录着每一天 Leetcode @itgoyo/500Days-Of-Github
0 stars 0 forks source link

25 Find the Duplicate Number #31

Open zwkcoding opened 5 years ago

zwkcoding commented 5 years ago

Problem Limitation: You must not modify the array (assume the array is read only).

if not ,the use sort first ,then linear search with O(n) You must use only constant, O(1) extra space. Your runtime complexity should be less than O(n2). Force search is refused There is only one duplicate number in the array, but it could be repeated more than once.

Two solutions: