"If you wanted to be rich in the 1800s you did it with Labour.
In the 1900s with Capital.
Now you do it with code."

@naval

In the series of solving @Leetcode daily challenges, we've an awesome problem today, 2 more days to finish a month, let's see how we can solve it.
@naval @LeetCode Find and Replace Pattern:
Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb"
Output: ["mee","aqq"] problem statement
@naval @LeetCode Well, coming to solution part:

Approach 1:
-> we're given a set of strings, let's do it for one string to compare with given pattern.
-> For any string to a pattern of given 'pattern' string,
-> Both length must be equal
-> The number of unique characters must be equal approach 1 code.
@naval @LeetCode -> Now, we come to comparison part where,
-> we map every character of given string with pattern and check a bijection matching in every iteration.
-> If it passes, means it has a same pattern as wanted.
-> Now we can generalize it to n strings.
TC: O(m*n)
AS: O(m*n)
Verdict: ✅
@naval @LeetCode Approach 2:

->As we mapped every character in the previous approach if
->>> we map them with their first occurrence index, we can get a numeric pattern.
-> Eg: "abab" = 1212 and "pqqp" = 1221
-> This way we can make patterns for every string, if they match with given pattern, approach 2 code.
@naval @LeetCode ->We count them in our answer.
TC: O(m*n)
AS: O(m*n)
Verdict: ✅

Auxiliary space is counted from output array.
It was an easy kind of problem, just to figure out how things going on, hope you've understood.
@naval @LeetCode That's a wrap!

If you enjoyed this thread:

1. Follow me @Iampatelajeet for,
🧑‍💻 Coding,
🌐 Web Development,
👻 free ka gyaan,
😁 tech stuffs and
🫂 Making new friends.
2. RT the tweet below to share this thread with your audience, it would be very helpful for me. 😍

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Ajeet Patel || Leetcoder

Ajeet Patel || Leetcoder Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Iampatelajeet

Jul 30
It's better to solve one problem everyday instead of solving 10 once in a week.
~Consistency

In the series of solving daily @LeetCode challenges, let's see today's really interesting problem.

#100daysOfCode Image
@LeetCode Problem statement:

You are given two string arrays words1 and words2.

A string b is a subset of string a if every letter in b occurs in a including multiplicity.

For example, "wrr" is a subset of "warrior" but is not a subset of "world".
@LeetCode A string a from words1 is universal if for every string b in words2, b is a subset of a.

Return an array of all the universal strings in words1. You may return the answer in any order.

Example 1:
Read 13 tweets
Jul 28
I was going through the threads of @Julian, I found some on startups, writing, career, storytelling, audience building, mental models, thinking and more which are not less than a goldmine, if you are eager to learn.

I'm gonna read them one by one, you shouldn't miss this. 🧵
@Julian -> Another perspective of seeing the world, it's not how you think:
Read 10 tweets
Jul 28
“A son asked his father, why the sun rises in the east, and sets in the west. His response? If it works, don’t touch!”. You know why? 🤔
Coz, his father was a programmer. 😅

Well, jokes apart, in the series of solving @LeetCode, let's see today's problem. Banner
@LeetCode We've an easy problem, "Valid Anagram": Given two strings s and t, return true if t is an anagram of s, and false otherwise.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
@LeetCode Example 1:
Input: s = "anagram", t = "nagaram"
Output: true

Example 2:
Input: s = "rat", t = "car"
Output: false
leetcode.com/problems/valid…
Read 9 tweets
Jul 25
How to center a "div" in CSS??

Sometimes it becomes very confusing and takes a long time.

So, here are 10 ways to do that, learn in the simplest way possible and save time.

A thread🧵 introductory image.
We'll be using 2 HTML div's
-> parent container
-> child container

Our aim is to center the child container with respect to parent.
We have this initial HTML, CSS files. HTML codeCSS codeiniti
1. Center using position property:

This property in CSS defines how the element is positioned on the page. The default value of the position property is static. The other values that the position property takes are relative, absolute, fixed and sticky. 1st approach
Read 19 tweets
Jul 16
I'm sharing @LeetCode daily challenge problems here, with my approaches from brute force to optimized.

Here's a thread of all problems I've shared, I'll be adding them here in future too.
Read 16 tweets
Jul 16
Some @YouTube channels that have helped me in my coding journey very much.

Not in any order, a thread. 🧵
TakeUForward: One of the best for CP & DSA lectures taught by @striver_79 bhaiya.
youtube.com/c/takeUforward
@Priyansh_31Dec YT channel, useful for doing CP.
youtube.com/c/PriyanshAgar…
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(