Interview Problem: Number of Substrings in a String that are Palindromes

preview_player
Показать описание
2:26 Concept of finding number of substrings in a string that are palindromes.
4:02 Code for the problem.
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
Coding Ninjas is one of the leading EdTech company providing India’s Highest rated programming courses in C++, Data Structures and Algorithms, Java, Python, Machine Learning, web development, Data Science, Android Development, Kotlin, React.

-----------------------------------------------------
------------------------------------------------------
Explore more on our social media platforms:
Рекомендации по теме
Комментарии
Автор

Join our Coding Ninjas official telegram community here:

CodingNinjasIndia
Автор

Hi sir, I am having a doubt that you are considering continuous characters as a substring
If we are choosing character not from continuous positions no of possible substrings can be 2^n -1

tarunkumar-kzxi
Автор

Well I am able toh solve the question when you said firstly we want solution and do not think about complexity thankyou bhaiya😊

roshanya
Автор

subscribed. Thanks for such a great explanation.

samaryadav
Автор

Very easy explanation i could found here. thank u very much.

piyushsharma
Автор

Can you please explain, how to get all possible palindrome substring?

moneymoney
Автор

public class Solution {
int count = 0;

public int countSubstrings(String s) {
if (s == null || s.length() == 0) return 0;

for (int i = 0; i < s.length(); i++) { // i is the mid point
extendPalindrome(s, i, i); // odd length;
extendPalindrome(s, i, i + 1); // even length
}

return count;
}

private void extendPalindrome(String s, int left, int right) {
while (left >=0 && right < s.length() && s.charAt(left) == s.charAt(right)) {
count++; left--; right++;
}
}
}


check out my solution

joydeeprony
Автор

I am afraid it won't work for input strings "aaa" - odd length and "aaaa" - even length

varunejanthkar
Автор

In this video, you will learn how to find number of substrings in a string that are palindromes.
2:26 Concept of finding number of a substring in a string that is palindromes.
4:02 Code for the problem

CodingNinjasIndia
visit shbcf.ru