Find element that appears once | Find missing number | Max Consecutive number of 1's | Arrays Part-3

preview_player
Показать описание

Problem links.

We have solved the above problems, and we have gone from brute force and ended with the most optimal solution.

You can follow me across social media, all my handles are below:

0:00 Introduction of course
0:57 Missing Number
18:16 Code-compiler (Missing Number)
18:44 Maximum Consecutive number of 1's
21:06 Code-compiler (Maximum Consecutive number of 1's)
22:49 Find the number that appear once and other number twice
36:40 Code-compiler (Find the number that appear once and other number twice)
Рекомендации по теме
Комментарии
Автор

Let's march ahead, and create an unmatchable DSA course! ❤

Use the problem links in the description.

takeUforward
Автор

In an interview, I personally feel jumping to "better" solution is good, instead of "brute" solution, if "better" exists that is.
Reasons:
- I dont think the time constraint allows for us to cycle through all three(brute, better, optimal) in 45min-1hr time window (usually 2-3 questions can be asked).
- Also brute are confusing at times, as it mostly involves combining many steps at times and the dry run will take time, so will the psuedo code.
- We must also account the stress of the interview, I don't think I can come up with different version of solutions for a single question without messing up the flow (which might ruin the concentration and cause panic). So I think its better to give a solution that you know it works for sure.

ariobotgaming
Автор

#Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India....

shubhamagarwal
Автор

are you planning to put Scaler Academy out of business.?? 😆😆

sharathkumar
Автор

Striver shouting top oof voice and these DSA problems are getting slightly one after the other in my head. Thanks Striver

Akash-yrif
Автор

0:00 Introduction of course
0:57 Missing Number
18:16 Code-compiler (Missing Number)
18:44 Maximum Consecutive number of 1's
21:06 Code-compiler (Maximum Consecutive number of 1's)
22:49 Find the number that appear once and other number twice
36:40 Code-compiler (Find the number that appear once and other number twice)


Please please please maintain consistency it's a humble request from the bottom of my heart 🙏🙏.

ParasSharma-mfor
Автор

You did a great job.... I used to afraid of dsa at first but the day I find your channel, I'll be more confident now to clear dsa rounds . Your hard work deserves a lot Striver. You explanation is crystal clear and it's keep us engaging with each step of concept.

merlingrace
Автор

I absolutely love your videos man! I understood everything very well. Internship season is gonna start very soon in my college and this helps me a ton!

actuallynxiss
Автор

For the last problem Find number that appear once and other twice the below code passes all the 11 test cases
int getSingleElement(vector<int> &arr){
int ans = 0;
for(int i=1;i<arr.size();i = i+2){
if(arr[i-1]!= arr[i]){
ans = arr[i-1]
return ans;
}
}
return arr[arr.size()-1];
}

pranavrakhunde
Автор

bhaiya its mean a lot for us who can't afford a course...! and providing this level of lectures such a next level....! i will try to be a like you in future so i can help the peoples in other way....! thank you bhaiyya

Deena_Bandhu
Автор

Corrected code for missing numbers:
class Solution {
public:
int missingNumber(vector<int>& nums) {
for(int i = 1; i <= nums.size(); i++) {
bool flag = 0; // Initialize the flag inside the outer loop

// Use nums.size() - 1 as the upper limit in the inner loop
for(int j = 0; j < nums.size(); j++) {
if(nums[j] == i) {
flag = 1;
break;
}
}

// This block should be outside the inner loop
if(flag == 0) {
return i;
}
}

return 0;
}
};

tabrezahmed
Автор

you are real hero for me.
best teacher
like done 😊

GB-sugu
Автор

Absolutly loved it, for the first problem in this video, I actually tried to solve it on my own, and thought of an solution which turns out to be a optimal solution you metioned here in this video, this is not a small achievement for me😃. Thank you striver.

_meetmakwana
Автор

Understood everything, you are one of a kind Striver!

helloworld
Автор

Extraordinary way of teaching. I never thought I would be able to solve all these questions quickly. Thanks man

Josuke
Автор

you're the best, man! hats off to you for great teaching and concepts that you elaborate so smoothly, i'm second year btech student and i am so thankful to have found you! ever since you came to my college for techtalk i've been motivated and a fan of yours, keep up the good work!

reki
Автор

Hey Striver, i had a question since you're working in Europe.Do European tech companies also ask a lot of DSA in their interviews or is it more focused towards other topics like design , LLD etc ? Would really love a video on this .

john_doe_
Автор

As the input array is already sorted, we can use binary search to find the single element in the array.

public int singleNonDuplicate(int[] nums) {
int low = 0;
int high = nums.length - 1;
int mid;
while (low < high) {
mid = (low + high) / 2;
if (mid % 2 != 0) {
mid -= 1;
}
if (nums[mid] == nums[mid + 1]) {
low = mid + 2;
} else {
high = mid;
}
}

return nums[low];
}

fnlxgvj
Автор

Thank you for all your videos! You have no idea how much these are helping everyone out there!!

AarzooBansal
Автор

There's a little mistake in pseudocode

Timeline: 27:10

The size of hash array will be (maxi+1)

maxi = arr[0];
for(int i=0; i<n; i++){
maxi = max(maxi, arr[i]);
}

hash[maxi + 1] = {0};

sameer_