Count Prefix and Suffix Pairs I | Brute Force | Trie | Leetcode 3042 | codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=xg7z7VVsYIg



Game:
Duration: 0:00
6,123 views
306


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A

Trie Playlist -    • Word Search II (Google, Amazon, Meta,...  

Hi Everyone, this is the 8th video of our Playlist "Trie : Popular Interview Problems".
Now we will be solving a good practice problem based on Trie and string - Count Prefix and Suffix Pairs I | Brute Force | Trie | Leetcode 3042 | codestorywithMIK

Problem Name : Count Prefix and Suffix Pairs I | Brute Force | Trie | Leetcode 3042 | codestorywithMIK
Company Tags : Will update later
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Trie/Count Prefix and Suffix Pairs I.cpp
Leetcode Link : https://leetcode.com/problems/count-prefix-and-suffix-pairs-i


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Segment Tree Concepts Playlist :    • Segment Tree | Introduction | Basics ...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
Trie Playlist -    • Word Search II (Google, Amazon, Meta,...  
Difference Array Technique: Concepts & Qns :    • Introduction | What | How | Differenc...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel :    / @codestorywithmik  

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


Video Summary :
Approach-1: Brute Force
Compares every pair of words to check if one is both a prefix and a suffix of the other.
Extracts substrings for comparison using the substr function.
Straightforward but involves repeated substring operations.

Approach-2: Using Trie
Builds two Tries for each word: one for prefixes and one for reversed suffixes.
Efficiently checks if smaller words are prefixes and suffixes of larger words.
Optimizes lookups using the Trie structure, avoiding redundant comparisons.


✨ Timelines✨
00:00 - Introduction
00:43 - Motivation
02:21 - Problem Explanation
05:19 - Brute Force using find()
11:04 - Brute Force using substr()
14:01 - Using Trie
26:36 - Coding it up
40:12 - Time and Space Complexity

#MIK #mik #Mik
#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 #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik




Other Videos By codestorywithMIK


2025-01-15Bitwise XOR of All Pairings | 2 Simple Approaches | Dry Runs | Leetcode 2425 | codestorywithMIK
2025-01-15Neighboring Bitwise XOR | 2 Detailed Approaches | Dry Runs | Leetcode 2683 | codestorywithMIK
2025-01-14Minimize XOR | 2 Detailed Approaches | Dry Runs | Leetcode 2429 | codestorywithMIK
2025-01-13Find the Prefix Common Array of Two Arrays | 3 Detailed Approach | Leetcode 2657 | codestorywithMIK
2025-01-13DSA Shorts with MIK - 9
2025-01-12Minimum Length of String After Operations | 2 Approaches |Intuition |Leetcode 3223 |codestorywithMIK
2025-01-11Your don’t need paid course for DSA
2025-01-10Construct K Palindrome Strings | Super Detailed Intuition | Leetcode 1400 | codestorywithMIK
2025-01-09Word Subsets | Simple Thought Process | C++ | Java | Leetcode 916 | codestorywithMIK
2025-01-08Counting Words With a Given Prefix | Brute Force | Trie | Leetcode 2185 | codestorywithMIK
2025-01-07Count Prefix and Suffix Pairs I | Brute Force | Trie | Leetcode 3042 | codestorywithMIK
2025-01-06String Matching in an Array | Simple Approaches | Leetcode 1408 | codestorywithMIK
2025-01-05Minimum Number of Operations to Move All Balls to Each Box | Leetcode 1769 | 3 Approaches | MIK
2025-01-05Shifting Letters II | Leetcode 2381 | Difference Array Technique: Concepts & Questions - 2 | MIK
2025-01-04Introduction | What | How | Difference Array Technique: Concepts & Questions - 1 | codestorywithMIK
2025-01-02But bhai….
2025-01-02Number of Ways to Split Array | Simple Thought Process | Leetcode 2270 | codestorywithMIK
2025-01-02Maximum Non Negative Product in a Matrix | Recursion | Memo | Bottom Up | Leetcode 1594 |DP On Grids
2025-01-01Count Vowel Strings in Ranges | Simple Thought Process | Leetcode 2559 | codestorywithMIK
2024-12-312025 Placement Roadmap | How I Would Have Prepared | Year 2025 Special | Happy New Year
2024-12-31What is special about year 2025 ?