Тёмный

HackerRank - Sherlock and the Valid String | Full solution with examples and visuals 

Nikhil Lohia
Подписаться 45 тыс.
Просмотров 14 тыс.
50% 1

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 68   
@eliezermoreno
@eliezermoreno 2 года назад
Thanks for the clarifications!
@surendharv795
@surendharv795 Год назад
Awesome Explanation sir. I am very eager to see more videos on your problem solving
@amansharma-ww7tv
@amansharma-ww7tv 3 месяца назад
must say really great explanation!!!!
@nikoo28
@nikoo28 3 месяца назад
Glad you liked it!
@divyagupta1562
@divyagupta1562 2 года назад
i was trying to solve it by looking to geeks for geeks and many more site, but could not understood. Way you have explained is just commendable. Thank you so much
@nikoo28
@nikoo28 2 года назад
Glad I could help you out
@misaelpereira9679
@misaelpereira9679 2 года назад
Man, you saved my life!
@yashikatomar6961
@yashikatomar6961 3 месяца назад
amazing explanation
@chandrakumara6534
@chandrakumara6534 2 года назад
very good Explanation and easy to understand
@simonkaranja3811
@simonkaranja3811 2 года назад
Excellent. You are a genius
@shantanu2322
@shantanu2322 2 года назад
bhaiya mtbl gajab .....fabulous,excellent mindblowing, very impressive,zabardast
@nikoo28
@nikoo28 2 года назад
Thanks for this amazing feedback 😄
@nilabhrabhattacharjee8707
@nilabhrabhattacharjee8707 3 года назад
Wrong time complexity. In between you are sorting the array of frequencies. Best sorting algorithm will take O(NLog(N)) times at worst case. So, that will be dominant.
@nikoo28
@nikoo28 3 года назад
I agree, we have sorted the array. But the maximum number of integers in the array can be just 26. That is because of the length of english alphabet. So, sorting actually happens in linear time.
@madhurajput452
@madhurajput452 6 месяцев назад
Amazing explanation!!👏
@nikoo28
@nikoo28 5 месяцев назад
Glad it was helpful!
@MunniDivya
@MunniDivya 6 месяцев назад
Great explanation
@tusharchandra2000
@tusharchandra2000 11 месяцев назад
I agree with the others. You explained it very well.
@tusharchandra2000
@tusharchandra2000 11 месяцев назад
I looked you up on Linked In. I am also from Kanpur and did my MS from ASU. Graduated in 2005. Working in the SF Bay Area.
@nikoo28
@nikoo28 10 месяцев назад
happy to connect.
@shubhamsharma-ec3re
@shubhamsharma-ec3re 3 года назад
You nailed it🔥🔥🔥
@nikoo28
@nikoo28 3 года назад
To my viewers, the InstaPwn thing is a scam. Don't fall for it.
@BtrmaAbhishekVerma
@BtrmaAbhishekVerma 3 года назад
Really really good explanation!!!!!!!!!!
@PB-ki8ys
@PB-ki8ys 3 года назад
WOW, THANKS !
@Vibewithgautam
@Vibewithgautam 3 года назад
wooaahh, easily explained.
@buuzinta
@buuzinta 5 месяцев назад
Did your complexity analysis account for the sort for both time and space?
@jjoelthomas
@jjoelthomas 7 месяцев назад
Can you please clarify why we need "first == 1" in if(first == 1 && second == last) return "YES". Because, with the previous condition, if(first == last), we will get to know that if first and last are matching. Now first is not matching. That's why we come to the second condition. At this point, first can have either 1 or 3. So checking first == 1 , is it valid? I checked in HackerRun without "first==1" and it runs fine for all testcases
@nikoo28
@nikoo28 7 месяцев назад
you are correct, that is not needed.
@maninderbakshi9147
@maninderbakshi9147 3 года назад
Great!
@yuntiangu
@yuntiangu Год назад
fucking lovely. Thank you so much.
@srinivas1694
@srinivas1694 11 месяцев назад
Since we used Hashmap, I think the space will be O(n)?
@tusharchandra2000
@tusharchandra2000 11 месяцев назад
No, what he said is correct. Since there are only 26 alphabet the max size of the map will be 26 - which is a constant. Hence, O(1).
@dineshchoudhary-yx7un
@dineshchoudhary-yx7un Месяц назад
In which programming language sir r u explain
@aniketroy2656
@aniketroy2656 3 года назад
I was trying to solve this Q only using strings and arrays...but I guess it is not possible, right? ( can we somehow do till the step where we receive an array "arr" with just using strings and arrays?)
@nikoo28
@nikoo28 3 года назад
I agree that this problem looks like a "string" problem but from what I learned while solving, it is more of a logical puzzle which involves a little math. Using string algorithms are usually slow and won't be solvable in the given time constraints.
@aniketroy2656
@aniketroy2656 3 года назад
@@nikoo28 Right right... Thanks!
@sealovingsoura3036
@sealovingsoura3036 3 года назад
Please make a video on maximum palindrome hackerrank bcz there is no video in that no one can make me understand like u
@nikoo28
@nikoo28 3 года назад
use the channel info to dm me about the problem statement.
@gokulakannan3664
@gokulakannan3664 Год назад
Time complexity: O(n²) ? Bcz, we sort the array
@nikoo28
@nikoo28 Год назад
You only have a limited character space. 26 different characters. This type of sorting is done in O(n)
@nikoo28
@nikoo28 Год назад
Watch my videos on sorting to understand more
@fagunraythatha5601
@fagunraythatha5601 Год назад
Hello Sir, you have some great videos. But I have one question, as we use array.sort() : best time complexity that would give us is nlogn by quick sort. So, how is your whole solution is n??
@fagunraythatha5601
@fagunraythatha5601 Год назад
Also sir, in our last if, we decided first==second and second == secondlast, why did you used second and secondlast rather than just first == secondlast ??
@nikoo28
@nikoo28 Год назад
I agree, we have sorted the array. But the maximum number of integers in the array can be just 26. That is because of the length of english alphabet. So, sorting actually happens in linear time.
@nikoo28
@nikoo28 Год назад
As per your second comment, yes we could have just compared first and second last…i missed that somehow and added the extra check.
@fagunraythatha5601
@fagunraythatha5601 Год назад
@@nikoo28 Got it, thank you
@himanshukrdiwedi4554
@himanshukrdiwedi4554 2 года назад
Very nice but very less problem your Channel contain
@nikoo28
@nikoo28 2 года назад
I am adding more and more problems day by day. Your comment and support keeps up my motivation.
@pro__gamer867
@pro__gamer867 Год назад
the time complexity will we nlogn
@anubhavnegi4230
@anubhavnegi4230 Год назад
i nearly got it on my own, but didnt know how to traverse values in map associated to key in java.
@nikoo28
@nikoo28 Год назад
Check out my video on HashMap to know more :)
@amansrivastava9890
@amansrivastava9890 3 года назад
Bro, TC is O(n logn) you have sorted the array..
@nikoo28
@nikoo28 3 года назад
I agree, we have sorted the array. But the maximum number of integers in the array can be just 26. That is because of the length of english alphabet. So, sorting actually happens in linear time.
@swarajprakash6021
@swarajprakash6021 3 года назад
Code show main method not found..?
@nikoo28
@nikoo28 3 года назад
yes, you will have to write the main method on your own. Just create the method and call the function available on my github profile.
@gopinath7846
@gopinath7846 3 года назад
possible try to solve merge two sort array without extra space please its confusing
@nikoo28
@nikoo28 3 года назад
Please try to be a little more specific with your concern.
@priyankanarisetti8327
@priyankanarisetti8327 10 месяцев назад
The above solution is not working for two test cases
@nikoo28
@nikoo28 10 месяцев назад
Check out the code on my github profile. Link is in the description. It passes all test cases on LeetCode
@priyankanarisetti8327
@priyankanarisetti8327 10 месяцев назад
@@nikoo28 Yeah, i have verified in github. But for Hacker rank it is not working.
@dineshchoudhary-yx7un
@dineshchoudhary-yx7un Месяц назад
There are 18 errors in your code when i run in cpp language
@nikoo28
@nikoo28 Месяц назад
the code is in JAVA
@shubhamsingh5434
@shubhamsingh5434 3 года назад
I guess we missed something in the questions here. The problem statement says - "remove just 1 character at **1 index** in the string", and we considered removing any 1 character from every index it appears. Or at least, that's what I understood.
@nikoo28
@nikoo28 3 года назад
That is what the question says...you can remove just 1 character from any 1 index.
@sonalisinha325
@sonalisinha325 3 года назад
must say really great explanation!!!!
Далее
Əliyev və Putin kilsədə şam yandırıblar
00:29
Просмотров 198 тыс.
How He Got $600,000 Data Engineer Job
19:08
Просмотров 24 тыс.
Əliyev və Putin kilsədə şam yandırıblar
00:29
Просмотров 198 тыс.