🌟 [ 6 ] Counting Words With a Given Prefix | Brute Force | Trie [ @ ]
( 1462 viewed : 120 like : 28 comments ) Whatsapp Community Link : [ 🔗 Click here 🌐 ‼️ ] Playlist -
[ 🔗 Click here 🌐 ‼️ ] Everyone, this is the 9th video of our Playlist Trie : Popular Interview Problems .
Now we will be solving a good practice problem based on Trie and string -
Counting Words With a Given Prefix | Brute Force | Trie | Leetcode 2185 | codestorywithMIK
Since this is a fairly small problem, hence I will also code it in Java in the video itself. Hope that helps.
Problem Name : Counting Words With a Given Prefix | Brute Force | Trie | Leetcode 2185 | codestorywithMIK
Company Tags : Will update later
My solutions on Github(C & JAVA) -
[ 🔗 Click here 🌐 ‼️ ] Link : [ 🔗 Click here 🌐 ‼️ ] DP Concepts Playlist : [ 🔗 Click here 🌐 ‼️ ] Graph Concepts Playlist : [ 🔗 Click here 🌐 ‼️ ] Segment Tree Concepts Playlist : [ 🔗 Click here 🌐 ‼️ ] Recursion Concepts Playlist : [ 🔗 Click here 🌐 ‼️ ] Playlist -
[ 🔗 Click here 🌐 ‼️ ] Array Technique: Concepts & Qns : [ 🔗 Click here 🌐 ‼️ ] GitHub Repo for interview preparation : [ 🔗 Click here 🌐 ‼️ ] : [ 🔗 Click here 🌐 ‼️ ] : [ 🔗 Click here 🌐 ‼️ ] : [ 🔗 Click here 🌐 ‼️ ] to my channel : [ 🔗 Click here 🌐 ‼️ ] Summary :
Approach 1: Brute Force
This approach iterates through all the words and checks if each word starts with the given prefix using find(). If a match is found, the count is incremented.
Time Complexity: O(n⋅m), where n is the number of words and m is the prefix length.
Space Complexity: O(1).
Approach 2: Using Trie
This approach builds a Trie data structure where each node stores the count of words passing through it. After constructing the Trie, it efficiently retrieves the count of words with the given prefix by traversing the prefix path.
Time Complexity: O(n⋅l+m), where l is the average word length and m is the prefix length.
Space Complexity: O(n⋅l), for storing the Trie.
✨ Timelines✨
00:00 -
Introduction
00:22 -
Motivation
01:32 -
Problem Explanation
02:19 -
Brute Force using find() or substr()
04:31-
Using Trie
16:49 -
Coding in C
26:07 -
Coding in JAVA
#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 [ 2025-01-09T03:20:45Z ] :flashminiupdate:2025-01-09 :::: Check it out >> [ 🔗 Click here 🌐 ‼️ ]
[ 6D ] Counting Words With a Given Prefix | Brute Force | Trie Words [1]
Interesting Keyword >> CountingWordsWithaGivenPrefixBruteForceTrie