Initially, I have came up with the following ugly solution, which includes complex board checking and hard to understand. It's very important for us to know when to start a new window. When the value of count reaches the length of t, this. Now we start traversing the string s and keep a variable cnt which increases whenever we encounter a character present in string t. In this approach, we create an array named frequency to keep a count of occurrences of each character in string t. We should also maintain a count variable for counting the useful character in the window. Minimum Window Substring Solution 2: Optimal. Which requires adjust right side (word in the window must the exactly same)!!!ģ. Take a look at this problem: https: // /problems/substring-with-concatenation-of-all-words/ We don't need to adjust on right side(which makes problem much easier). Since this problem does not care to include extra characters into the window, as long as the subset of the window meet the condidation. To maintain the slide window, we need to adjust the left side and right side of the slide window. ![]() ![]() Prepare two hashmaps, one is to record the characters appear target String, the other one is to record the characters appear in our slide window.Ģ. It's an important pattern to slove a cluster problem over string : Permutataion, Substring, Concatenation.īasic idea: maintain a slide window to circle out the target String. Wondering if there is a beach inside the body.The idea behind this problem is very very important!!! Meditation is all about breath-in and breathe-out, that's it? Are you kidding me !! All this while I have been owning this body unaware of its functioning.ĭid you know? - Your blood has the same amount of salt in it as the ocean does. Me NOW (While reflecting on life): □□♀️ That's how easy our life is made with abstraction.Ĥ. To give you guys some context, the print function that we all used for our very first "HELLO WORLD" program is an abstraction over a huge instruction set. I eventually understood how abstraction is everywhere. But abstraction still did not make sense. Trying my best to apply theoretical computer science knowledge to the real world. After all that's an inherent nature of OOPs right? To me abstraction was just defining a class and exposing some of its functionalities. That's how you learn□ Ukulele and Algorithms, both□Ībstraction means displaying only essential information and hiding the details. Moral of the story: Apply algorithms wherever you want to. Also, maybe I should have mentioned Music as prerequisite for reading this post□ ~Me: Still decoding how well that analogy would fit in□įor those who don't know, Ukulele is a musical instrument.(Just to clarify, before people think I am talking about some software). ~Friend: (Still □□) Isn't this similar to the Word Wrap problem using Dynamic Programming? Given a set of words and limit on the line width, you have to find the optimal way to break the words into separate lines? And I tell him how organically he would know when to transition to a different chord" ![]() ~Me: It's simple dude, just follow the rhythm and scale. chord C to chord A)? At what point in a sentence should I break and move to the next chord? ~Friend: How do I know when to transition from one chord to the next (e.g. Here is an excerpt from our todays conversation. ![]() Me being 2.5 songs into Ukulele, was giving my expert advice to a friend. I am here to share a funny yet beautiful yet inspiring incident.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |