Longest palindrome substring - LeetCode Interview Coding Challenge [Java Brains]

preview_player
Показать описание
Interview Question: Find the longest palindrome substring from the given string

Difficulty level: Medium
Language: Java

Welcome to the Java Brains Java Interview challenge series of videos where we tackle various coding challenges ranging from the beginner level to advanced level - especially in the context of coding interviews.

Any coding problems you would like me to explore? Please let me know in the comments what you think!

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

"resultLength = end - begin - 1;"
it is not due to 0 indexing of Java. It is math. While finding inclusive length between two points you have to add 1 to its difference. eg. ZABBAV will be 4 - 1 + 1 = 4 chars long . You did "begin--" and "end++" before you break out of while loop which offsets the begin-end range by 2 units. Your correct start is "begin + 1" and correct end is "end - 1". The inclusive length of the substring thus is (end - 1) - (begin + 1) + 1 (due to inclusive range) which is equal to "end - begin - 1".
Apart form that, a big fan of your teaching. Your tutorials helped me land my current job.

robdai
Автор

I watched your previous palindrome video last month on the day before my interview and guess what? I got 4 hackerrank problems to solve and 2 of them were about palindromes !! AND I GOT THE JOB 😍
Thank you sir!

crteezy
Автор

Does anyone feel - What the hell I am doing with my life?Is our life all about all these LC this give you fulfillment? Philosophy apart for the good explanation

NimbuCB
Автор

i understand your solution, but i feel like i would have never been able to think of this solution on my own. its discouraging sometimes :( thanks for explaining everything so clearly!

Daniyay
Автор

I did a very complex solution where there was a nested loop and I put how many times I had a roll it back and it passed every test case. However, it would not be accepted by LeetCode because it runs out of time because it is way too complex. I'm glad I found this video to give me a better way to try it.

Granta_Omega
Автор

Man this is the best explanation for this question, I have been struggling with this from so long. Thanks a lot!!

vinayakgupta
Автор

Your video really helped. Thank you very much. Just a suggestion: if you can take an example and walk through the solution towards the end, that would be awesome

prafullakh
Автор

Please correct me if I'm wrong but there's no need to call expandRange twice. You can simply check if, and only if, either the character left or right of the center is equal to the center. Because you can only have a palindrome with a 2-character center if both characters at the center are equal, otherwise it's no longer a palindrome.

annonymousarmadillo
Автор

Thank you for the excellent explanation! Special thanks for the "clean code" and expressive method/variable names-- rare to see that in LeetCode problem solution videos!

abhijitpatwardhan
Автор

Very cool video, as always. One small mistake in your explanation in my opinion. The result length is equal to end - begin - 1 not because zero index but because when one subtracts end - begin, it gives you the difference and not the number of indexes included. For example if we have 1, 2, 3, 4, 5, 6 and begin = 2 and end = 5, the length is still equal to end - begin - 1.

johnnygr
Автор

please keep on these leetcode series they are really helpful and fun to watch.

TheSumitSagar
Автор

Very helpful. You have explained it in detail to make it easy for everyone to understand. Thank you!

ayushisinghal
Автор

Thanks kaushik for such a wonderful explanation, big fan of teaching style

ALEEMKHAWAR
Автор

I really love these videos. Your explanations are extremely helpful and easy to understand, please make more!

MegaValture
Автор

This explanation was so easy and so well explained. I am really happy I found this video. Thanks, Java Brains !!

shafiaaskari
Автор

Great!!
Feedback: Do a walkthrough of the code at then end.

AmanRaj-tjlj
Автор

we are running expandRange twice for even and odd length. Can't we put a check if(length %2) and accordingly call one of them? If we can't then please provide an explanation. Can't find an answer to this

vartikasingh
Автор

There exists an algorithm to solve this in O(n) time - Manacher's agorithm. But nice explanation of the O(n^2) solution.

bewareofnikhil
Автор

I Watched all your video and i am not able to understand even an single question

-ritikjain
Автор

That's the best explanation for the palindrome.
You are perfect 😍😍😍😍😍

youssefmyh