AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Minimum window substring java12/10/2023 Step 5: If all the character of string B is present in the current substring and the length of the current substring is smaller than the length of ANS update ANS to current substring. Step 4: Check if all the characters of string B are present in the current substring. Step 3: Iterate through SUBSTRINGS from beginning to end. Step 2: Make a string ANS and initialise it to A. Step 1: Generate all the substrings of the string A that have a length greater or equals to the length of the string B and store them in SUBSTRINGS. We can find all the substrings of the string A that have a length greater or equal to the length of string B (as substrings of A that have a length lower than the length of string B cannot contain all the characters of the string) and then we can check which are the substrings that contain all the characters of string B and output the smallest one out of all these substrings. Here, we can clearly see that there are two substrings of A that have all the characters in string B and those are "bcd" and "abcd". If there is no such string, then the answer will be an empty string.Įxplanation: Here's all the substrings of string "abcd" ![]() We need to find the smallest substring of A that has all the characters in B. Wondering if there is a beach inside the body.Given two strings A and B. 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. For example, S'ADOBECODEBANC' T'ABC' Minimum window is'BANC'. Trying my best to apply theoretical computer science knowledge to the real world. Minimum Window Substring (Shortest Substring from Pangram) Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). 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
Read More
Leave a Reply. |