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
@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: ✅
->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,
@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.
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. 😍
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:
“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.
@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
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🧵
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.
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.