Are you doing okay today? You don't have to upload a video if you don't feel good. Take the day off my man
@steven8Ай бұрын
I think it's easier if you use slicing to extract each substring and then join the substrings with a space: res = [] prev_start = 0 for end in spaces: res.append(s[prev_start:end]) prev_start = end res.append(s[prev_start:]) return " ".join(res)
@TheMarcelismАй бұрын
Great and simpler and easy to understand. Thanks!
@sdemjiАй бұрын
dynamic arrays are the main culprit for the bad runtime, reallocation happens in the background when pushing elements, or checks for reallocation and bookkeeping operations, so even tho yhou brushed it over at the beginning, a three pointer approach with a fixed sized array would probably perform better. Ohter than that, class on grass
@hargovind2776Ай бұрын
Yeah bro Take care, get some break and rest, clear your mind
@lightlegion_Ай бұрын
It's impressive how fantastic your content is!
@madhurkhyani9671Ай бұрын
def addSpaces(self, s: str, spaces: List[int]) -> str: ans="" idx=0 for i,char in enumerate(s): if idx
@aaryatupe007Ай бұрын
Thank you for posting such tutorials ! You are amazing
@ThinkOutsideTheBox12345Ай бұрын
Awesome Explanation!!!
@__samuel-cavalcanti__Ай бұрын
Why this approach is better than creating a new array or spaces with m+n size then just copying ?
@ahmedtremoАй бұрын
Thanks man
@OgrizkovАй бұрын
Why would you iterate each character if you could use slicing. In Java yes, two pointer approach more efficient than substring
@lendr.oАй бұрын
can you do 2382, been struggling with this one
@potansiyel7021Ай бұрын
We need to research your brain. I think your brain has changed after all these leetcode questions.
@mrf92Ай бұрын
bro you solve POTD when the question is reasonable then discontinue when the question is actually hard. why??
@jad_cАй бұрын
he doesn't owe you anything
@ajaygupta6034Ай бұрын
he's trying his best to manage things, don't doubt him, he could've recorded this video earlier as the POTD solution comes in editorial a few days before. He can't sacrifice himself for you, someone who doesn't even value his hardwork!!! (Thanks for the great explanations Neet!)
@mrf92Ай бұрын
@@ajaygupta6034 look I feel bound to reply back, because this comment is made highlighted by the creator. I asked this question because he said earlier he loved making leetcode videos over his job in google/Amazon. Now It's not like I or someone else is dependent on this account to solve leetcode problems. generally I solved a problem on my own then, sometimes throw a glimpse on different solution videos, editorial, for any new approach that I ain't familiar with before. I myself solved over 1k leetcode problems. brother don't think you are indispensable, no one actually is in this world. don't get arrogant, keep your foot on the land.
@ajaygupta6034Ай бұрын
@@mrf92 First of all, I'm sorry if I came across as arrogant, although I'm not talking about myself at all. Yes, fosure finding new approaches to problem is one of the joys of leetcode, but all I am saying is respect that dude, he doesn't look like someone who just quits when the obstacle is tough lol, but sometimes you're just not left with enough to do things you love unless you do them at your expense, and I think he's been doing that already for some time, so cut the guy some slack lol. Also how were you able to see highlighted by creator, like what's that?
@aaryatupe007Ай бұрын
Hi, I need help with these questions: Maximum Frequency of an Element After Performing Operations I and Adjacent Increasing Subarrays Detection II. Please could you provide a tutorial on this!!
@rsaisiddhuАй бұрын
Hello I have uploaded my explanation in my KZbin channel - kzbin.info/www/bejne/ZmKZgKSHbJ6mp5Ysi=Jxvo8OhISE2eRhZS May this helps
@leeroymlg4692Ай бұрын
I found my solution to be a little bit simpler: res = [] p = 0 for i in range(len(s)): if p < len(spaces) and i == spaces[p]: res.append(" ") p += 1 res.append(s[i]) return '"".join(res)
@davi_singhАй бұрын
My solution was almost the same as yours :D. Happy to see I am catching up a little ``` res = '' space_idx = 0 for i, c in enumerate(s): if space_idx < len(spaces) and i == spaces[space_idx]: res += ' ' space_idx += 1 res += c return res ``` I was using a string on purpose as I thought it would be more efficient but looks like i need to go deeper into that part