Find First Palindromic String in the Array | Multiple Ways | Leetcode 2108

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

This is the 4th Video of our Playlist "Solving only using C++ STLs/JAVA JCF".
In this video we will try to solve a good practice problem - Find First Palindromic String in the Array | Leetcode 2108
Using STLs/Library functions only like reverse (C++, JAVA) and std::equal (C++)

Problem Name : Find First Palindromic String in the Array | Leetcode 2108
Company Tags : will update soon

Approach Summary :
Approach-1 Summary:
Method: Creating a reversed string for each word and checking if the original word is equal to its reversed form.
Time Complexity (T.C): O(m*n) - m = number of words, n = max length of words.
Space Complexity (S.C): O(n) - Space used for creating the reversed string.
Details: Iterates through the given words, creates a reversed string for each word, and compares it with the original word. Returns the first palindrome found or an empty string if none is found.
Approach-2 Summary:

Method: Using the equal function to check if the first half of the word is equal to its reversed second half.
Time Complexity (T.C): O(m*n) - m = number of words, n = max length of words.
Space Complexity (S.C): O(1) - Constant space as no additional space is used.
Details: Iterates through the given words, checks if the first half of each word is equal to its reversed second half using the equal function. Returns the first palindrome found or an empty string if none is found.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear
Рекомендации по теме
Комментарии
Автор

Sir, OOPS Concepts Videos in C++ will be helpful too by your crystal clear explanation ❤❤

utkarshsahay
Автор

bhaiya if possible we need a video on stl comparators, if you get time please make a video on it and explain the following
1) how to write comparators
2) comparators on priority_queue vs vectors vs sorting {priority queue behaves differently for min and max heap thats why}
3) why do we write static for some comparators
would be a great help :)

dhairyachauhan
Автор

Har video me I you are always willing to give some new knowledge. This makes you stand apart. Love this attitude.

aws_handles
Автор

class Solution {
public:

string words) {

for(int i = 0; i < words.size() ; i++)
{
int n = words[i].size();
if(words[i] == string(words[i].rbegin(), words[i].rend()) )
return words[i];
}

return "";
}
};


class Solution {
public:

string words) {

for(int i = 0; i < words.size() ; i++)
{
int n = words[i].size();
if(equal(words[i].begin(), words[i].begin() + n/2, words[i].rbegin() ))
return words[i];
}

return "";
}
};

class Solution {
public:

string words) {

for(int i = 0; i < words.size() ; i++)
{
int n = words[i].size();
if(words[i] == string(words[i].rbegin(), words[i].rend()) )
return words[i];
}

return "";
}
};

tusharnanda
Автор

Thanks a lot bhaiya ❤❤ Bahot kuch naya sikhne ko mila is video se 😀

gauravbanerjee
Автор

Pls explain in detail mancher algorithm for LPS in upcoming videos. Thank you

ADK
Автор

Please bring solutions for weekly contests as well

Ashutosh
Автор

bhaiya *"string( rbegin(word), rend(word) )"* aur *"string( word.rbegin(), word. rend() )"* dono same hai kya ?

anshumaan
Автор

Bhaiya DP playlist ka notes nhi mil payega kya aapke iPad wala? If possible pls send it 🙏

Stressful_Jindagi
Автор

hey brother can u send a link to ur notes for today's question, it helps us build intuition! thank you :)

project_eth
Автор

Bro can you please solve the Leetcode contest questions?

rahulmandal
Автор

Bhaiya recursion ki new video kab Ari ?

User-student-
Автор

Can we use STLs like priority_queue in interviews ?

souravjoshi