Single Element in a Sorted Array - LeetCode May 12 Challenge

preview_player
Показать описание
540. Single Element in a Sorted Array - LeetCode explained.
In this video we'll:
- analyze description for binary search hint
- break binary search into odd/even case
-------------------
Try it yourself here
Рекомендации по теме
Комментарии
Автор

In this video:
- analyze description for binary search hint
- break binary search into odd/even case

daose
Автор

I tuned in just for the tip on odd vs. even to help me solve the problem! Glad I can implement binary search easily now. After watching your solution though I learned my code had many more conditions than it needed to in it! I'm happy I can consolidate it down to something easy to read and write :D

codycodes
Автор

Nope! The intuition explanation can't be any better !

pahehepaa
Автор

Great Explanation...
I did it like this ::

int i=0, j=1;
int n = nums.size();
while (i < n && j < n)
{
if (nums[i] != nums[j])
{
return nums[i];
}
i = i+2;
j = j+2;
}
return nums[n-1];

phenomenalprince
visit shbcf.ru