filmov
tv
Find First Palindromic String in the Array | Multiple Ways | Leetcode 2108
Показать описание
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
Комментарии