Single element in a sorted array | Leetcode #540

preview_player
Показать описание
This video explains a very important programming interview question which is to find the unique element in a sorted array in just O(logN) time and O(1) extra space. This problem would have been extremely easy to solve provided we were allowed O(N) time. This can be solved by simple linear search or XOR operation. In order to take benefit of sorted array property, we can use binary search algorithm with some observations to find the unique element in just O(logN). I have shown 4 observations and used them to solve the problem in O(logN) time using binary search algorithm.At the end of the video, i have explained the CODE. CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

Рекомендации по теме
Комментарии
Автор

Easy approach to toughest of the questions...This man is simply a legend !! 🙌🙌

NeverGiveUp
Автор

Finally understood this question after seeing four different videos.Thanks a lot🙏

TechBroQuiz
Автор

class Solution {
public:
int nums) {
int n = nums[0];
for(int i=1;i<nums.size();i++){
n=n^nums[i];
}
return n;
}
};
using xor

aniruddhabhattacharya
Автор

very nice and different solution thanks alot I was very confused how will we change the left and right values but this video helped me clear my doubts.

satyamgupta
Автор

it is most easy approach that i have seen on youtube, thanx

nitesh
Автор

You are the best channel for these solution videos! Your explanations are so clear and are very helpful for me during the job search!!!

angrybutterflys
Автор

Shocked to see that you have around 90k subscribers . You deserve atleast 500k subscribers dude !

shreyasvishwakarma
Автор

Amazing, i saw a lots of video but i did not clear the concept but you are amazing and you know how to teachs

wasimahmad
Автор

Great Explanation better than anyone on YouTube!!

ajaygonepuri
Автор

Thanks a lot Surya! Couldn't think of this approach myself.

yitingg
Автор

Wonderful explanation, and I am thankful for your efforts which help me to understand the concept.

saraswatirathore
Автор

u explained it so u r simply a legend !! 🙌🙌

oqant
Автор

thanks a lot, very easy to grasp ur explanation

gautamtyagi
Автор

can you make some videos on hard graph, DP and trees problems.
Please make some videos on binary lifting, euler tour, etc and their questions. I have just listened their names and don't have idea that what are they, and its confusing to studying codes, your videos are helpful for that purpose. Please make some videos on these topics and cover some hard questions which are asked in interviews

ArpitDhamija
Автор

Please upload more and more videos. Your video is very helpful

rahulbhalla
Автор

nice bro
why i like u because
my approach && my thinking ==your approach + your explanation

letsdoeverythinginoneweek
Автор

Your explanations are gems. Thanks sir.

cristianouzumaki
Автор

explained beautifully, you earned a sub 👍

ChapalArchive
Автор

This will works when duplicate elements exits in pairs

tejailla
Автор

TechDose: I have one query, after seen the logic Its very easy to understand the approach .But could you please help me how should I build my own logic or approach to solve the any problems of programming. Thanks

varunoyal