Count Prefix and Suffix Pairs I | Brute Force | Trie | Leetcode 3042 | codestorywithMIK
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