This video demonstrates how to solve algorithmic problems efficiently by recognizing mathematical patterns and using appropriate data structures. The presenter solves multiple LeetCode problems, including counting words with prefixes, finding matrix diagonals, reconstructing binary search trees from pre-order traversal, and calculating sums of odd-length subarrays. The key insight is that complex problems often have elegant mathematical solutions when you identify the underlying patterns, such as using a stack for the special discount problem or recognizing that the sum of odd-length subarrays follows a specific mathematical formula based on array indices.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
~5.6 hours of the easiest LeetCode problems!Added:
here. Let's see if this is working.
Let's give this a shot. Um, so yeah, today I'm going to try to do eight hours of programming and see how far we get.
Let's make sure it's working. Do eight hours of programming and see how far we get. My uh my hair is a little messy today.
>> Do eight hours.
>> Um, all right. So, first question is going to be counting words with a given prefix. Let's take a look.
Uh, excuse me one moment. Here we go.
Okay. Yeah, I think my hair is maybe a little bit. I might need a haircut.
All right. Give an array of strings, words, and stringing prefix. Return the number of strings and words that contains prefix as a prefix. Prefix of strings contiguous substring best.
Okay, this is a pretty straightforward one. So, we're just gonna say const auto auto check prefix.
Um, I'm going to subretain this.
It's going to be um prefix.
This should also be by reference.
Um, this should be a string and we're going to say uh for loop.
So, we're going to say b check equals true return check. Actually, just return true should be it.
And now we're going to say int i is zero. I is less than prefix size.
Um I is less than s.
I say if prefix of I is not equal to s of i return false.
In this case we could write our own custom check prefix and then we can have um return stood accumulate of have a few things. It's going to be words begin words end words end zero and then this sub routine.
It's going to call um check prefix with prefix and con string s and accumulate.
And we're going to say return accumulate loss check prefix of fast.
I think that's it. I think that's what we need.
Let's see. Uh let me just check and see that the stream is working fine. How's my hair look? I think it's um see uh let me just I'm not sure. How's my hair look? I think it's um let's see uh it's a little messy. I need a haircut. Definitely need to get a haircut, but the stream is okay. Stream health. Um let me go ahead and continue with the problem. So, it looks like that was this the right way to go. Let's give it a shot. See how it goes.
Let me do it on time also. I'll let that take a few minutes. Oh, it's wrong. No.
Oh, that's brutal. Okay.
I'll put one expected zero.
Oh no.
I I made an error here. There's there was a slight error here. I I knew I was taking a small risk writing this custom code. I forgot something very subtle here. It's important.
Um if if this string is smaller uh yeah yeah so it's going to be pref size has to be less than or equal to s do size.
That's that's what I missed.
I thought I got that case but I I didn't think it all the way through.
That was my mistake.
Kind of I like thought I got it, but I didn't get it. Yeah, that was that was my my mistake. That's subtle.
That was bad on my part. Let's submit it one more time so it feels bad. Um, o to say about that. I have no excuse. No excuse for that.
I thought I got it, but I I I didn't think think hard enough about that one.
Very slight slight uh thing.
A square matrix mat return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements in the second diagonal that are not part of the primary diagonal.
Sum of the matrix diagonals.
Primary diagonal, secondary diagonal.
Oh, okay. That's it.
All right, that's not too hard. So, some of the diagonals look pretty straightforward. It's just going to be uh int result zero. Oh, let's just double check that this fits constraints.
Um, only 100 by 100. Yeah, it's going to fit an int. It's fine.
Um okay so it's going to be I Z less than square to size plus I solve plus equals M of I I and then the other direction um which is almost the same thing.
Um, so this one it starts off the row and the column increment in the same direction. This one you just go another direction. So um the row is still I but the column is N minus I think minus one. Double check it's minus one or not.
Um where N is meant size. So it's going to be the first row but the last column which is at size minus one and then I had zero. So yeah so it should be this one I think this oh it's wrong shoot. Okay 30 25 what is uh it should be one oh but you only add oh the middle element shouldn't be added twice. Okay, now there's a slight there's a slight mistake here and that's because they're adding the middle element twice. So if uh map do size and one if it's odd then we're going to say result minus equals do size um the middle element which is like uh do size by two I think we're going to bit shift one actually it's bit shift to the one left.
I think we subtract that. That's kind of subtle, too. It's a good thing I didn't submit that.
Yeah, that's a subtle thing.
See? Um, yep. Okay, we'll submit again so I can just double check the time in the stream health. Also, take a look at my hair again. Stream is healthy.
Each time I touch my hair, I kind of maneuver it around a bit. It looks okay.
So, nine minutes, two questions in nine minutes is okay.
I'm trying to keep track of like how quickly I could solve these because I should be able to solve them kind of fast.
That one's not a very tough one. And none of these are really that tough.
This one's solved already. So, we'll just quickly explain it.
Okay. Constructing the binary search tree from a pre-order traversal.
Um this is a tricky one. Basically um a pre-order traversal is going to give you the the initial node then the left subree then the right subree and it recursively. So then that left subree for example is going to be the initial node the root node and then another split into left sub tree and right sub tree. So the way this would work is um in order to get the to reconstruct the binary search tree, you would have the root and then you'd have somewhere to the right is going to be the um so the first root then the left subree is going to have the the next element is going to be the root of that that node that tree and then somewhere to the right is going to be the root for the right subree. The tricky thing thing here is it's not clear um where the right subree begins. Um excuse me. So I think it's going to have to be because a binary search tree you can scope ahead basically and find where that right subree is going to be.
Um, and then you and then you can create the then you can basically recurse on that that element. Um, I think it's still linear time if you do it this way even though you're doing this sort of extra these extra steps of like kind of going over to the side. The reason why I think it's fine to do that is because you're only when you move over to the right to find the next element like the next subree I think you only ever go move further to the right so like when you recurse on that right subree for example um the left subree starts immediately to the sides there's no cost constant cost there and then when you recurse again on the right subree it is you're only going to keep going to the right further. So because even though you do a significant amount of work moving to the right initially or at least when you first find that right subree overall the overall amount of work over all those sub trees is going to be at most linear at most uh so it's amortized uh linear or amortized constant basically over all those operations. So you can do that just fine. So basically you can just um root node is first node next element is the left sub tree root node recurse almost not exactly recurse but almost recurse before you recurse. Scan to the right until you find the first element that's larger than the root node. That's going to be the beginning of the uh Oh, no, excuse me. That's um yeah, that's necessarily going to be the beginning of the right subree because it's a pre-order traversal, which means that that root that element is always going to be that first element is always going to be the root root of that right subree. I think this is correct. I think you can do it this way. I could be wrong, but I think that's the way to do it. I've saw this already, so at some point in my life, I knew the answer, but we're going to we're going to skip it. I think that's the way to do it. Um but uh that's how I would do it now if I did it again. Okay. So, but that's I think the way to do that. Um I'll maybe come back maybe at some point I'll come back and and try it again. Pgram is a sentence where every letter of the English alphabet appears at least once.
Sentence string containing only lowerase letters turn true to penagram false.
Okay. True or false? So this is a pretty straightforward one. Um basically just use a full frequency or has uh as letter right. Um and make this empty initially uh fill this letter.
Um for con charge in sentence it's also um turn in count zero. Um, actually we could even I mean just thinking how how big are these?
I think we want to optimize this a little bit.
A thousand. Okay, that's fine.
We'll just keep it simple. So, uh, we're going to say has letter of chus a or equals with um true.
I think we I think we just set it to true actually.
And then um return stood accumulate of has letter six um z= 26 something like this. I think it just be equal to 20 26 is fine but something like this works I think. Let's try.
Yeah, I think that's it. Let's go for Yeah, very straightforward.
Just basically save uh in a like a boolean um set set of bulls like or array of BS whether or not those characters are there or not.
Cells in a range on an Excel sheet.
Cell row column of an Excel sheet is represented as a string. Column row interesting where column denotes column number C of the cell is represented by alphabetic letters.
The first column is denoted by A second B so on. Row is the row number of the cell. So given a string s the format column one column row one column 2 row two and give me an example column row represents such that R1 R2 okay so it's going to give you like a subsection of a of a grid the list of cells such that this is true um the cell should represented as strings in the format above be sorted in non-dereasing order first by columns then by rows uh sorted in nondereasing order first by columns and then by rows.
Oh, okay. Column and then row. Oh, that's interesting. It's a column, row order.
It's a little bit unusual, but yeah, it's kind of somewhat inverted, but so column and then row. Okay.
Usually it's row column.
Um, so K1, K2, L1, L2. Okay.
Column and then row. All right.
Um, huh.
Interesting.
So, it's going to give you kind of a subsection. And then we got to do column row list.
All right. Um little odd, but I think I can handle this.
um can also let's just see okay it's between a and z and one and nine all right um interesting so constant row one row one or K1 or C1.
It's going to be CS of zero A C2 is U I think three zero one two three yeah three uh R1 is R2 it's one and four I And this is minus zero. These are characters. So, uh yeah, second one is the row and then um third, fourth, fifth, the fifth characters, right? Okay. A little bit confusing, but um so we're just going to convert. So, we're going to say for int row equals R1. Actually, we should do column. Yeah, column column order.
column C1 C2 column row R1 row is listed R2 row um and then return result and this is going to be resultserve Um, it's going to be I think the R2 - R1 * C2 - C.
I think that's how many elements I need.
I think that's right.
And then we're going to use um so we've got to convert these strings.
So result pushback um a string like it's going to be uh consistent mode maybe string I'm not really sure actually can I construct the string this I could try. Um, so um I wonder about this. I don't know.
String.
Let's just say next or we'll just call it s.
Not really sure.
I'm going to move it anyway just to see how this goes. So the column comes first and the row comes next. The column character is going to be um plus a I think I have to think about this a little bit more. And then the row is going to be plus one or I think just plus zero.
It's something like this. I don't I got to think about a little bit. What's up?
Hello. How old are you and what's your background and current situation in tech? Hello, sir. What's up, Nico Rocket League? Welcome. Howdy. Uh up in my 30s.
Uh my background I was I worked on algorithmic trading systems for uh the corporate world. Um did like client services for buy side equities.
Um and uh current situation in tech I'm currently looking at so I have a degree T8 a course in computational geometry when I was younger. Uh worked almost four years in the corporate world.
Um I've been programming for like 20 years like since I was a kid. uh almost 20 years uh on it. Not working currently as a developer though because I'm kind of in a weird place in life. I I've been looking more at like doing um mentorship tutoring and or coaching um and doing some YouTube make some YouTube videos uh at the moment and yeah I work at the moment I don't work in tech explicitly at the moment I do uh um I just work in fast food at the moment which is pretty pretty easy or I shouldn't say it's easy it's It's different. It's a little easier than tech in my opinion. Runtime error out of bounds.
Uh undefined behavior UB. That's a That's unusual, huh?
Um index 75 conchar.
What did I do here? Huh?
I might need to think about how I want I don't want to use a string stream for this, but that's one way of doing it.
Um, I mean, I could do it this way, too.
This is probably easier. There's a few ways to do this. I think let's try this. Let's see what this does. This is This may not be the best way to do it. I'm sure there's better ways to do it. There's like Yes, there's like subtleties of string manipulation that I'm like not super familiar with.
Um, yeah, there we go. Straightforward.
That works. I mean, this wasn't the best solution because it was it just took a while to program. Um, it's reasonable, but it it's like not the best. All right. How we doing on uh uh what's the health of the stream?
Okay. Not just buffering a little bit, I think.
Okay. Let's just give it a moment to stream buffering. Also, what's the health of the stream? Okay, not just buffering a little bit, I think.
Okay, let's just Okay, doing better now.
All right. Um, sweet. So, yeah, I mean, that's that's an okay solution.
Um, but yeah, I mean, as far as employment, like the last recruiter I spoke to, they were looking at um well, I I shouldn't get into all that. like the the roles that I apply for now. Um some of them pay like 350,000 a year and some of them pay like half a million a year. Um but I'm kind of not too excited about those rules for various reasons.
Final prices with a special discount in a shop. You were given a an integer array prices where prices is the price of the item in a shop. There's a special discount for items in the shop. If you buy the i item, then you will receive a discount equivalent to price of J where J is the minimum index such that J is greater than I.
And prices of J is less than equal to prices of I. Otherwise, you will not receive any discount at all. Alternative array answer of I final price you will pay for the item shop considering a special discount. Okay.
Item zero price receive a discount price four minus four is four. What is the okay we get the integer array special discount i item equivalent to price j the minimum index such that j is greater than i and price j is less than price.
uh otherwise there's no discount. So there's got to be some element to the right. How many elements are there in this array? This is like kind of a look ahead question.
Okay, it's only 500. So I mean we could do a very basic approach.
It's the first element to the right that's smaller basically.
Um, I mean a look ahead's fine.
I'm wondering if I should use a stack to do this. Might be easier, more efficient.
A brute force solution is fine here.
Like you just look ahead for each element, but a stackbased solution basically you push the element when you see it.
Um, then when you push then when you see an element that's smaller, you pop everything from the stack that's larger and push the smaller element on.
Yeah, that's the way to do it. Stack stack works nicely.
Excuse me.
Stack's pretty solid here.
So vector results um reserve prices of size.
Then we're going to have a for loop a stack.
I'm going use a vector as a stack.
Same deal.
Uh then return prices.
Um we're going to say just do this prices.
You can actually even go further. You can do it like this.
X and prices doesn't really matter. So gonna say for um st.top is greater than x pop.
So st not empty.
And then we're going to say the following.
We're going to say result pushback st minus x right push and pop and then um t push back it's actually it's because I'm using vectors it's going to be back.
Pop back.
Um, yeah.
And then ST push back X. Something like this, I think, is what we want.
Wrong. What did I do wrong?
I'll put eight. So uh we have x is the price st is empty so we skip push x which is eight onto the stack. Then we see four um and then we say okay uh the stack which has eight it's not empty has eight is greater than four we're going to push on the result we're going to push 8 minus 4 so we should have pushed 8 minus 4 oh I returned prices that's why excuse me should return salt.
That's okay. I was like, where is my logic ring gear? What did I do? Oh, it's wrong there.
Okay. Uh 442 should have been.
So, push the four, we pop eight, then we push four onto the stack.
Oh, I see the issue. Then we put six onto the stack, I think.
Um, oh, you know what? It might be.
It maybe should be a Q actually, not a stack.
Yeah, I think I'm supposed to push four minus two before I push.
If I do it this way, I'll have I'll push four and two, not two and four. It'll be the wrong the wrong sequence but also it's um I see what I'm missing here. Okay, that's subtle. So for um empty uh Can't I did it slightly slightly incorrectly and just I think I need to dump the rest of the elements in there. So I do need to use more like a Q than a stack.
Yeah, these are these are going to be in the wrong wrong orders.
Okay. Um Okay. Interesting.
So, what's interesting about this is that um I don't think I need to use a Q necessarily because this is going to always be a a max.
Um Oh, no, no, no, no. It's it's it's correct. It's just I just need to reverse this, that's all.
It's a bit awkward.
Yeah, it's a little awkward.
We're going to do it like this. This is a little awkward, but I think this is right.
Yeah.
Okay. So, we're going to do the following.
Um, and then and then we dump this into the result.
Um, it's actually going to be more like this.
Yeah, it's a little awkward. It's a little awkward.
something like let me see what was this wrong. Okay, hold on.
Okay. Yeah. Yeah. So, I got I did re I did do this middle part correctly, but the last part's just slightly incorrect.
Um, just did the same thing as this here.
Um, just Let's see.
Okay.
Still wrong.
Uh oh. These are not supposed to be reversed.
Is that it?
Okay. a little bit better.
There's something wrong here. Um.
Oh, I think they Oh, the Oh, less than I'm sorry. That's my mistake. Um, I'm sorry, but I shouldn't say I've been saying I'm sorry a lot lately because I have co-workers that are very Oh, I shouldn't say that either. I shouldn't say that either.
I've been working lately and I apologize a lot to my co-workers because uh I don't know what else to say quite frankly.
I don't know what to say. I don't want to upset my co-workers. So, I just apologize constantly.
Uh is this easier to do it that way? I think I don't know if it's easier to do that way. I have no idea. This seems to be correct, but I'm not sure if this is the best way to do this.
It's wrong. It's not correct either. Of course not.
>> Uh I might be trying a little too hard on this one. The the the approach I described earlier would be sufficient for the time balance and I probably should just use that one, but part of me feels like I should try to do something a little more sophisticated here. I'm surprised this is wrong.
What happened here? Uh, okay. So, I had the one here.
94.
Um, you know what? There is actually a better way to do this. There's This is just wrong, I think. Hold on. Let's go back back to the drawing board here.
Actually, I had the right idea the first time around. I just didn't think it all the way through.
So, I did actually, not that I did it correctly the first time, but I was close the first time. Uh, I I think I know I'm doing it wrong here.
So, what it's supposed to be is the indices, I think, in this stack.
Um, so I do need to do Yeah. Okay, let me do it this way.
Um, in this case we can do something like the following.
All right. Uh, stack empty stack back. So it's going to be still going to have a stack but it's be a stack of indices.
So it's going to be prices stack back and then we're going to not push back but we're going to write to the index result of ST back is going to be equal to prices.
Yeah, this I think is what I was supposed to do initially. I just kind of didn't think it all the way through, I guess. And then then we push X back on back of the stack. Yeah, I think this is what I'm supposed to do. Supposed to be index based. Um, and then I just write the indices at the end. So, um, yeah, that's just going to be push back, not push back, but result of the index the pointer.
And then we do prices of it's just going to write basically this something like this.
Let's see.
Um oh and x is uh price of y.
I could just do constant x.
Um, yeah, I think I I kind of goofed this. I kind of Yeah, I kind of goofed this. Okay.
Buffer overflow. Okay.
Of course. Um.
Oh, no. No. Push X. Whoops. Push I. That That'll do it. Yeah, that'll cause buffer overflow.
All right, there we go. That's correct.
Yeah. Um, I goofed, man. I goofed.
I don't know what to say. I should have I should have thought that through a little bit more from the beginning. Um, it's more of index based kind of thing.
Uh, yeah. I don't know, man. No excuses for that.
No excuses for that.
That's uh there's other there's a few other problems that are similar to that, but yeah, that's a linear time solution rather than a uh a uh I don't know.
Yeah, no excuses. No excuses.
Um find elements in a contaminated binary tree. So, I've already solved this one. What are some of the uh things to say about this?
It's also linear time memory also that previous one binary true the following rules root.v val for any tree node. If tree nodev val is value x and tree node left is not equal to null and then tree node.v valals 2 * x + 1. Okay, true. Val has a value x.right is not equal to null. It's 2 * x + 2.
Okay, so it starts off with zero. If it has a node on the left, it's going to be twice that plus one. So it's going to be one. Then the one on the right is going to be two. Then the one if we repeat that times two is two + one is three on the right of that is so it's going to be zero one two three four five six and so on. So it's kind of like a um if it was a full tree it would be uh like a level order uh traversal of like the natural numbers.
um or yeah level order kind of a I don't know what the word is for that um placement of the natural order of the natural numbers starting from zero rather than the natural numbers the posit non negative integers non- negative integers so integers including natural numbers including zero now the binary tree is contaminated which means all tree nodev val has been changed to negative one no what implement the find elements class find elements ments. Initialize the object with a contaminated binary tree and recovers it. Find target returns true.
The target value exists in recovered binary tree. Oh boy.
Uh oh. Um okay. Interesting.
So So I've got to recover.
Huh.
and then have the find routine.
Interesting.
Well, the find each of the finds can be done in binary uh logarithmic time logarithmic and the I think the not exactly logarithmic. I'm not really sure actually the find is a little bit complex.
Um total number of nodes is 10,000. Total number of calls defined is 10,000.
Height of the binary tree is less than equal to 20. Okay. Well, if it's the height is less than 20, then yeah, you can do the find can be linear in the height.
But yeah, the it should be linear in the height. The basic approach.
See, like I said, I've already solved this one, so I'm not going to solve it again, but I'll just give a brief description of how you could solve this.
So, I would say I'm not sure it's really necessary to um actually modify the tree. I don't know.
I'm not sure if they're if the way they program this is actually going to check that. Um, null, true, false, false, true.
I don't know. I don't know if they even if they don't bother to check whether or not I mean the tree it's not that hard to recover the tree. It's I mean you could just do the whole thing. I guess it's fine. Um so you would you would literally just recurse from the uh simple recursion is fine and in order traversal is fine. So you would say or you could do pre-order is fine too. So you would set the root node to zero and then the left side and the right side.
Um you would uh you would just save the so in the recursion you just have an integer that that you parameter that you save like what the next value is going to be. So starting from zero you have you know 2 * 0 + 1 and then the other one will be 2 * 0 + 2 and so on and so you can recurse that way. So yeah pre-order traversal works fine.
um recursive approach and then that's if you had to write the new val the correct values to the tree and obviously if it's a null you just skip it um if the tree denotes null um and then the find you would just run on the tree um you know left or right depending on what you're searching for. So, uh whether or not the value is going to be in the left subree or the right subree is it's actually not that obvious where it's going to be. Um I have to think about that actually.
What does the find routine look like? Uh it's going to be let's see if you defined five. Let's do something more complicated like let's say you defined like um it says 10,000 nodes. Let's say you defined like 5,000. So, start off with zero.
5,000.
Um, that's actually a good question. How do you would you go to the left subry or the right subry for 5,000?
Um, good question.
Well, you have two options, right? You have either um subtract one and divide by two or subtract two and divide by two.
If it's even, 5,000 is even. If you subtract one and divide by two, you're going to get a uh an odd node.
That's 49 4,999, which divide by two gives you 2,450 plus half of 98 or 99, which is 48.
I think they both give you 2,998.
No, not 29. No, 2,498.
2498.
24,499.
Uh, let me think about that a little bit more.
5,000 - 1 4,999.
Divide that by 2. The 4,000 becomes 2,000. The 900 becomes 450. The 90 becomes 45.
So you get 2,495.
And the 9 becomes four.
2,499.
I think it's in both cases.
Yeah. So, actually in both cases you get 2,499 if it's odd, if it's even. If it's odd, um let's say it's 5,01, subtract one divide by two, you get 22,500.
If you subtract two and divide by two though, you're going to get not 2500, you're going to get um 2,499 again.
So, there is a different meaningful difference there. Uh, I'm not sure which one to expect.
Um, well, for sure if you divide by two, if you subtract by this one or two and divide by two, you're always going to get a whole integer because that's how these are generated, right? So it's clear then if it's odd you would you would do subtract one divide by two it's even you subtract two and divide by two and then you recurse several times until you get to the root node. Um yeah and then and then so you recurse several times or repeat several times till you get to the root node and then just reverse that process back down.
And if that if you have those nodes all the way through, then your find routine works. If not, then um you return false because you hit you'd hit some node where you're not you're not going to get the path the correct path to the value.
I think that's the way to do this.
That actually is substantially more complex than I thought it was going to be, but that should work. I think that's correct.
But yeah, that's that's a that's a more complex one, I guess. Um, let me see the chat is getting here. What's up, chat?
Hey, Pro guy. Welcome. How's it going, code guy? Hope everybody's going well.
Why don't you teach these topics on your channel? I would love to hear from a smart person in the community. I appreciate that. Thank you. Um, I should do that. I think that's a good call.
Your lead code ID, I want to follow you.
Subscribe. What's up? Well, welcome Devkin.
Devkin uh and unsharma.
Devk canand An unsharma.
I I appreciate that. Um okay, let me uh let me show you. Let me show you. So here here's my here's my Whoops. Um it's my lead code. Whoops.
There we are. Um, yeah, I've solved a few. I have a lot more to go, though.
Got a lot more to go. But I appreciate you. I appreciate the support.
Appreciate that. Um, yeah. So, I think that's going to be the way to solve this one. I think that's going to be the way to solve this one.
Um, we'll go to the next one, though.
I'm not going to code it because I already already solved it. But this one I solved, too. Okay, I'll explain this one, too. Sorting the sentence. Uh a sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowerase and uppercase English letters. Sentence can be shuffled by appending the one indexed word position to each word then rearranging the words in the sentence.
Okay. Um I have to think about that. For example, the sentence this is a sentence can be shuffled as sentence for A3 is to this one or is to sentence for this one A3.
Okay. Oh, the one index word position to each word and then rearranging the words in the sentence. Okay. So that's the shuffle. Okay. So you append the one indexed position to each word and then you and then you swap them around and permute the words. Okay, got it. Given a shuffled sentence containing no more than nine words, reconstruct the original sentence. Okay, so the trick here, the key here, excuse me, is to get split each each word on the um single white space, right? and then um figure out the index of that word from the last character, excuse me, of each of those strings and then rewrite recreate construct the string uh with those words in the correct spot.
So that's a really interesting I like this. This is a good question. I like this one. I've saw this one already, so I won't won't go through it again, but that's the basic premise basic approach.
And I think there's an easy way to do this in C++ using um uh you can use string find I want to say to find the space and then you can use the sub a string substring to get the word that's at at that string at this point. Um, and then you could write those into a um I think it's at most nine words. You could write those into a um a vector of words of strings. A vector of strings. You write each string into the vector of strings. Um, and then also save like an array of ind of integers that at the index of the string, you also have the index of that integer array which has the where which has like where it's going to go. And then you can read both off simultaneously and reconstruct the the string by just um concatenating. So um yeah uh well or you could see not the best way to do it. Um, I like I would I want to concatenate at the end, but I would say take the ah I got it. sort sort the um the array of strings that I've just created. Sort it using the array of positions.
Um and then concatenate then concatenate straight across. That's probably the easiest way to do it.
I like that approach. That's probably Yeah, I think that's a little bit easier because if if you make it a little more complex than that, then I think it uh gets a bit awkward.
Yeah, I think that works. Okay, I was going to say actually you could even do better than that. Instead of creating a um a second array of integers that keeps track of like what these values are, you can just dump the you can you can split the strings into these segments as mentioned and you'll get a like a vector of strings and then you can sort that vector of strings itself based off of the last character of each string.
That's might be a better way of doing it, easier way of doing it. And then and then when you read off you just you just exclude you just substring each each string excluding the last charact or you just you just pop the last character when you concatenate you can since you're creating this vector of strings anyway and I guess you could use a string view to keep make things a little bit easier if in C++ to be a little more optimized. Um but uh yeah that might be a little bit better actually to to reproduce this. Yeah, it's pretty interesting question. I like that one.
It's a it's a peculiar one. Basically taking a permutation and reconstructing the original. Um it's a cool cool idea. All right, let's go to the next one.
Um image message retract. What's up ECB?
Welcome. Hello.
All right. Oh, I saw this one too. Um find first palendroic string in the array. Given an array of strings words, find return the first palendroic string in the array. There's if there's no such string, return empty string strings palendrome if it reads the same forward and backward. Okay.
Okay. This isn't too hard. A couple things to say. So this is an array of strings. It's a little bit easier. But if it was just the first palendrome in the string, there's an algorithm for palendromes. It's pretty um comes up from time to time with palendroic questions called moniker's algorithm. So this would be monitors algorithm and when you're doing palendromes it's usually relevant. Um so efficient method for finding the longest palmic substring in a given string linear time introduced by Gladen K moniker in 1975. So this is they figured this out like 50 years ago more than 50 years ago. It's been known for over 50 years, which is pretty long time. Uh, but yeah, so there's an explanation.
Um, but I'm not going to explain it.
It's uh it's an interesting thing. It's um basically it's it's one of those algorithms that uh it's sort of a sliding window algorithm, I guess, if I had to summarize it. And um you it doesn't just find the the all the palendromes in the string. It finds uh like all of like at each index it'll find the size of a palendrome. I think it it's I think it's you could design it in a way where it will find the like to the right how many characters to the right of that position are going to match the characters to the left like how far that goes. sort of like a almost like an onion shell kind of a thing.
Something like that. Um I don't remember exactly Moniker's algorithm. I don't have it memorized but I kind of have it sort of me like I partially remember it.
But uh yeah that's moniker is comes up a lot. In this case though we don't need monikers. Um in this case we just check directly um if each string is a palendrome. So the way easiest way to do that is if it's an um even or odd uh the e really the easiest way to check if a string is palendroic is exactly what they described here. Just reverse the string and check it against itself.
So if if the string is equal to itself reversed then that's probably the most straightforward way to do it. But another way to do it is to just if it's odd, um, start the character on the left side, go left to right, and match that against the characters right to left until you've matched all the characters.
If it's even, then you would start sort of at the midpoint on the left side and match left to right with right to left.
Slightly more efficient than just copying the string and reversing it and and checking it directly, but um, it's not that much. It's not efficient enough where you would avoid that. Like in in an interview, you probably would just do the reversal because it's just way faster to program.
Um, but yeah, in this case, it's very straightforward. So, I'm not going to program that one because we've already solved it. But, um, that one's on the easier side for sure.
Um, hi. Hi. What's up? Uh, HG Suresh.
Oh, hello. Hello. Welcome. Howdy.
Everyday is going well. Welcome, welcome, welcome. We solved this one, too. Solved a bunch of these already, huh? Reverse words in a string three.
Given a string s, reverse the order of characters in each word within a sentence while still prever preserving whites space initial word order. So, the way this one works, um, you would I think I did this in Python probably. I don't know if I did this in C++. I probably did in Python. Um, let me see how long do I solve this. I saw this in 2019 in Python. So actually we'll do the C++ version. So this is basically a um what you do is you split into words.
Uh you no you I think you reverse the whole string split into um it's like a reverse split reversed kind of thing. I'm trying to remember exactly how this works. So uh yeah, if you reverse the whole thing, then split and then reverse each word.
No, that'll reverse the word order, not the character order. We want the characters. So this you would split into words, reverse individual words and then join.
Yeah, that works.
Um, let's see. Uh, okay. There's seizing space. So we we'll program this in C++.
This is too too bad. This isn't too bad.
Oops.
All right. So, let's try this result.
Um, we're going to say, so we want to do s.find. It's going to be a single space.
That kind of makes things a little bit easier.
And we're going to say position and we're going to say position if so position equals s.find find is not equal to or actually yeah it's more like this is not equal to um state stood string end position and then we say I want to say we increment the position something like this. Um, and then we're going to say const, no, not a const. It's going to be stood string.
Uh, temp is going to be s substring.
Come back to that in a moment. We're going to reverse the temp.
Um, and then we're going to append the results.
All right. Um position is going to start off at zero.
We're going to find this next position.
I think I have a previous to previous position zero as well.
zero position zero um previous equals position and it's going to be position + one I think something like this got to think about this a little bit um so and then we actually just add at the at the end here.
These might might want these to be up here.
Um, just got to run this one more time, I think, because this is going to end.
Oops.
Explain a minute why I got it one more time here.
could do it one more time because this is going to uh this is going to exit when the basically it's going to miss the last word if I don't if I am not careful here and the substring is going to be previous to the number of characters something like this where it's the previous position the number of characters is going to be the position of this minus minus the previous position. So like if you have ABC in a space, it's going to be 0 1 2 3. Three is the position we get. 3 - 0 is the number.
Yeah, I think it's pre position minus previous is the substring number of characters.
Um, and then we would say plus a space.
Um, same thing here. Previous and this one you don't get a space.
Something like this. There can be some off by one errors or something going on here.
Let's see.
TLE. Okay. Not what I would want.
Um, okay.
Oh, I know why. Um, find from position.
I think that's part of what I'm missing here. There are a lot of pieces to this, a lot of elements. Let's see. What did I get?
Uh, okay.
Okay. It's close but not quite right.
Um, why did it go in the reverse direction?
Um, wouldn't this wouldn't this take lets first?
Why did it Wait, what?
Temp substring previous position temp result plus equals temp.
Huh?
Why did uh Huh?
Wait a second. What is going on here?
Oh, I must misunderstood something here.
Huh?
What am I missing? Missing here?
Where's my uh Oh, wait a minute. What?
Oh.
Uhhuh.
Huh.
Oh, that's interesting. This this debug code isn't running.
Uhhuh.
Okay. I must have an error somewhere that I don't realize. Okay. Um, syntactical error somewhere.
Okay. Uh estind position space.
Let's look that one up. Um, it might be it might be better to do CP for reference. Perfect.
Yeah, this might be better. Let's do uh somewhere here. Strings.
This is I I tend to struggle a little bit with string manipulation because uh it's a bit complex in C++ and I tend to um so you guys can see what I'm looking at.
And I tend to um make very slight mistakes. I think I you could argue I just need a little more practice basically.
Where are the Here we go. That's what I'm looking for.
Um search.
Oh, wait. No.
Where's the find? There we go.
Okay.
Uh position comes after. Okay, that might be the issue.
Oops.
Where's the uh the uh position comes after? Okay.
Count character position count number two.
What's that? Find the first substring equal to the range s+ count. This range may contain null characters. If SS plus count is not a valid range, the bet is unfin.
What does that mean?
What does that mean? S+ count in the range.
First substring equal to the range ss plus count range may contain null characters.
I'm very confused by this. I don't know what can they give me example of this one.
Character string to search for count length of the substring. Oh, okay. I see.
I see. So, this just bounds the length of Okay, that's interesting.
Um, but yeah, I think the Yeah, I made this mistake before.
That must be what's going wrong.
That's why the debug's not printing.
There we go. Okay. I was like I was so confused. I was like, what did I do wrong here?
Yeah, the string manipulation can be a little more complex because of the um the extra sub routines involved and the syntax you kind of have to remember the correct syntax.
Okay, there there we go. So that's how you do that in C++.
Uh also I didn't really cover how you might do this if there was more than just a single white space.
Um like if there was more white space than just single spaces. That's a little more complex, but there are ways to do that, too.
Probably if you had more white space than just a single space. I think what I'd end up doing is uh I do something very similar to this find routine. But more likely what I'd do is I would alternate between searching for things that are not whites space as like a chunk of text and then searching for a chunk of text that is whites space and probably um I'd have to think about how exactly I'd want to handle that. Um, but I would likely take the chunk of text that's not whites space, reverse it, append it to my result, take the chunk of text that is whites space, not reverse it, append it, and then keep repeating that way. Um, something like that. Uh, but yeah, I would have to alternate each search procedure, toggle the search procedure.
Um, so it'd be a little more complicated programming that um the loop conditions would be different. I think I might have like a toggle like there's a way to toggle your loop conditions which is peculiar but yeah you just I've done that before. I've had I've had toggling for loop conditions. It's definitely very peculiar thing but you can do it.
I've done it before.
Um, all right. Let's see what uh what else here. Um, maybe keep this open in case I do more streaming stuff. Let me I need to actually charge my computer. Let me uh me check the stream health and then maybe I'll charge the computer. It's been like an hour, which is good. Stream is healthy.
Um, let's grab another question and then I'm going to go ahead and um grab another question and then go ahead and plug in my computer while I'm thinking about this question.
Sum of all oddlength subarrays. Given array of positive integers as array, return the sum of all possible oddlength.
There's my subarrays of ribs. Uh, interesting.
The oddlength subarrays. Well, that's peculiar. Uh, can you do this in linear? Yeah, I was going to say there's probably is a way to do this in linear time.
Gulp. Um this so the sum of all subarrays can be done pretty efficiently I think by um excuse me think about the sum of every subarray.
The sum of every subarray would be like adding each. So the the subarrays of size one, you'd add each element once.
Subarrays of size two, you'd add each element twice except the first and last element.
Um I think that's correct because there would be overlap summary for size three would be every element once twice three times across then twice and once again is the pattern.
Um, and then if you add these things all together, you have ones across, one, two's across, one, one across, two across, 1 2 3 across, 3 2 1. You add them all up, you end up with like three + 1 + 2 + 3 um 1 plus 1 plus 1 1 plus 2 plus 3 or yeah 1 plus 1 plus 1 1 plus 2 plus 2 1 plus 2 plus 3.
Uh interesting.
So like each element would end up being added like you could you could calculate that. I think you could figure that out.
How many times does each individual element get added if you added every sub all the subarray sums of all the subarrays together?
Excuse me. I think it's going to be for the first element and the last element it's just the size of the array n * 1 I think uh well I would say if it's a size four you do one size one size two size three and size four yeah before the n times the first element then the second element is n minus one * 2 + 1.
Then next elements n - 2 * 3 + 2 * + 1. And so it's going to be n - i * the index time x or yeah n minus yeah uh n - i * the index plus the sum from one to i.
uh yeah from 1 to i which is going to be I think i * i + 1 / 2 um and then that whole quantity. So n - i * i plus i * i + 1 / 2 that whole thing times the element and take that over the sum sum over the over all the elements.
I think that's the solution for uh just the sum of all the subarrays and then the sum of all the oddlength subarrays.
Basically, you're going to cut that down. Um somewhere in there you modify, excuse me, modify those values. So I think the i * i + 1 /2 term probably becomes more like uh i^2 because you're just you're just not adding the even values in between probably something like i^2 over maybe over two have to think about that a little bit more. And then for the even values, oh excuse me, not the even values for the other portion um where it like gets capped I guess.
Uh I think it just divide by two. So instead of instead of being n minus i times i, it's like n minus i * i / 2.
It's something like that. But yeah, I'm pretty sure this can be done in linear time. Just need a little bit of um I guess manipulation.
All right, let me go ahead and um let me go ahead and plug my computer in and then I'll come back. One second.
Okay.
All right. Um, give me one second here. Uh, all right. Back. So um let's try to do it in linear time. So as I mentioned, let's say it's going to be something like the following.
Uh I want to say this is a good question.
actually let's do it this way. The number of times this particular element gets added.
All right. Um, if the array is of length 1 2 3 4 5, we're adding one once for the size one, one once for size three, and one once for size five. So five, three, and one.
It's three times.
So it would be like 5 - 1 / 2 + 1 I'm going to use N to hopefully simplify things a bit.
Whereas if it was just um I is zero, right? The first element, it would be N minus I is five. But in this case, it's it's half of that plus one.
if it was even so six.
So I can I think yeah you subtract one divid by two and add one. I'm not sure I'm if it's six you would do one three and five again. It' still be just be divided by two.
So if it's even you divide by two. If it's odd you divide by two and add one.
Interesting.
And just think about that for a minute.
Do you add one? Ah, there we go. Add one first and then divide by two. That's easier.
Okay.
Add one first then divide by two. So five becomes six divide by two get three. Six becomes seven divide by two is still three. Okay.
All right. Um now how is that related to I however well let's say we shift over to I I is one how many times does four show up in the odd length subarrays?
Um oh yeah this was this was yeah one three and five right. So, this one's going to be also 1, three, and five, but it shows up twice in the three and twice in the five.
Um, yeah.
Let's do let's do it like this.
Let's do um it's like the first count and the second cow.
There two two parts to this.
This is going to be the like flat count and this is going to be the rising count.
I'm not really sure what to call those two things.
So, I'll call them these things. Call them this um So this expression minus I okay that may or may not be correct. I'm not sure about this. This actually this might be a minus I here or something. I'm not sure where this minus I fits in. I think about it. So for four I plus two is correct. It's twice um 1, three and yeah. Yeah. um in each of the subarray lengths that are three and five and so on. The ones that are greater than or equal to two, it's going to show up twice.
Each of those it shows up in the three length.
Three once, twice. It shows up in the five length once.
There's a rising. is a falling in a in a flat amount.
If this were if it were not odd length, it would be once for one, twice for two, three times for three.
Well, not three times for three.
Like the two is three times for three, but four is not three times for three.
Oh, that's confusing, huh?
Once for one, twice for two, twice for three, and only once I think twice for four, and only once for five.
Okay.
The reason why it's only twice is because um it's going to be the minimum.
It's because it's it's it's uh like locked on the side. I'm not sure how to express that.
it's because it it it's too close to the side. So even though you have these larger arrays, um they aren't going to reach this number more than two ways.
Oh boy.
So actually this flat part is a little more complex than I thought initially. Um it would actually be you'd actually subtract two of each I value.
So it only appear three times as four times two.
Um I think this basically this is doubled.
That's what I'm saying.
Um that's in that's if you just added all of the subarrays. But if you just added uh the oddlength subarrays, I think it' be three.
I think if I took n minus i, let's do it like this.
Um, the amount's going to be two for sure, but in this case, it would also be a two. Like for five, uh, five and four mirror each other.
um constant. I'm not sure what to call this. Like let's just say bound.
It's going to be the smaller of these. I + 1 and n minus i.
So if i is one, it's going to be the bound between it's going to be bounded by two. But if also I is 0 1 2 3 there's going to be n minus i which is five basically the indices on the other side.
So one and one 0 1 2 3 4 um smaller of these two.
So one and four plus one and then when you see four it's going to be one plus one is two. It's gonna be this bound and then so the flap flap count count is going to be multiplied by this bound.
And then also um that bound I guess defines how many of these other values are not included. um for that bone. So like at i equals 1, we're going to have these three. At i equals 2, it's just this middle element.
Uh and the other ones are going to be sort of rising values. Um so let me think about this.
Um, it's not I + one by the way. It's it's this bound. But what I'm multiplying by the bound is I want to say N minus bound.
Again, this is for if it's not odd length. Odd length is a little more complex, but let's just suppose it was not odd length.
Um, in this case it would be 5 - 2 is three of these.
Um, and then when I is 2, 5 - 3, that's not quite correct because this basically doubles at each iteration.
What's being removed?
Um their correct way to understand that would be like um it be sort of like bound minus one bit shifted to the right.
This I think is the correct flat count for non oddlength. So from i for i is zero.
Um the whole thing is a flat count which gives you bound is one um n minus 0 * 1 is n.
So that's what you would get for the first element. The number of times that shows up, it's five times which is correct. The rising cow would be zero there. For I is one.
Um I get this bound of two. 2 * 2 - 1 is one. Bit shift to the left is two. So we get one two of these excluded. three * 4 uh three times you would get two which is correct. It's going to be the one case, the two case, we get two. The one case gets excluded. Two case, the three case does this twice. The fourth case does this twice. And the fifth case also gets excluded.
So I think that's correct for the flat count. And then the rising count is going to be um we're going to do the it's basically n.
Um, so whatever the bound is a temp variable.
This might be easier.
Um, so this rising count is a little bit more complex.
Um, it's going to be the sum. So like if you're looking at two, it would be one plus two and then this one has a three.
Uh, and it's 1 plus two on the other side, too. So you'd multiply by two which is I already have that here. This this rising count times two.
Um this 1 plus two comes from I said I think we said the bound was two actually I think yeah yeah. So here here the bound would be three and we're going to have the sum from one to two not up to three. So we subtract one to two. So it's going to be the sum from one to two. Sum from one to two is going to be uh that value times itself plus one divided by two. So 2 * 3id 2 is three. Yeah.
Yeah. That that so this works for the um sum of all the subarrays.
But for the oddlength ones, things get more complex. So, those of you who have been following me so far through this, I appreciate that. This is definitely one of the more complicated. Um, if I just run this, I won't get the right answer, but I'll get uh I can at least verify that my thinking is correct here. So, I got 110 for this one.
So we get this sum five 6 7 12 15.
I don't know if I want to do all that by hand. That might take too long. Let me not try to verify that all by hand.
That'll take a while. Um the next thing is all right. How do I modify this for the odd counts?
Uh the odd odd length arrays.
I wonder if I just divide by two. That'd be kind of funny if it was that simple.
It almost looks like that. No, it's not.
Okay. I was gonna say if we could just divide by two. It' be nice.
It's close though.
Um let's see. Did it work in this case?
110.
Uh add these three. Add these two. Add these two. And then add each each three again.
So that would be 21 + 12 is 33.
33 twice is 66. And then add 76 uh + 12 is 88 and then plus 22. Yeah, I did get that did calculate that correctly. Um let's see about uh okay in the odd case now how does this change? Well the flat count is going to be um let's think about this again.
So, we're still going to do like let's say in the second case, it's still going to be a one, but we're not going to have the two in there um for the rising count.
So, the rising count is still going to count one, but we're not going to have it's not Oh, no. I'm sorry. Let's do Let's do the case. Let's do the middle one. Let's do three. It's a little bit easier to think about three. So for the rising count, um it's going to appear once in one and it appears once in and three.
So we do still get 1 + 2 there.
Um actually no, maybe it's better to try four. I feel like I need more elements to really understand this. Um, that's confusing. That's very confusing.
It's very confusing.
Uh, let's let's do four and then two.
Let's just do them separately and see see where it goes. So um in this case we do add one one time for the one case and we don't add two for the two case and we don't add two for the three case either. We do add two for the three case though.
Um do we add and we add one for the five case. So it becomes one two one instead of one two two one two two one becomes one two one.
Okay. So we lost two elements from the flat count. Basically um this section this part basically was divided by two instead of three multiplying by three we multiply by one and I think that's basically it actually just uh you just take this whole thing add one and divide by I think that's it.
So save account modifier.
Um, yeah, I can just add one. Add one and divide by two, right? Because it went from from three down to one.
Actually, no. I don't think he even I don't think he even had one.
I think you just straight up divide by two.
Yeah, three would go down to one. What is four? Four probably goes down to two.
Um, this doesn't have a four.
Yeah, it doesn't have a four. Um if you had a sixth element here then it would be at four here for the parts that would be counted um twice to be four times.
Um, in that case, what did I say? You just I was saying that it would be it'll only be twice. So, if there were six elements, you do two times would show up twice.
Three. No. No. Yeah. But that gets discounted. Three times shows up twice.
Four times gets discounted. Five times shows up twice.
Uh no, five times would only Yeah. Yeah.
Five times would show up twice. It wouldn't show up once. Now it show up twice. And then six times would get discounted.
So you'd have one, two, two. You would Yeah, it would. Yeah. Justide by two.
Okay. It seems a bit odd, but flat count modifier just divide by two. Um, and then that's for the odd case. And then the rising count is it's still going to be like for five it's 2 * 1.
Um, but this is a different formula here now.
So what happens now is like for in this in this case it's still just one right because you just have one and two two one two two and one but when it become when it's when it's the odd length subarrays it's 135.
So this is going to appear in the in one and in five still.
So that actually doesn't change in that case. We'll come back to that.
But in this case it would have been one two and one two.
Um but instead of being one two so the multiply by two I think on both sides is still correct but but um getting 1 plus two here I think is incorrect now because that would be for the one case the five case or the one case and the two case and the three cases where it's the three one case and two case but the two case is gone now that's what I'm saying so yeah it's it's just it's just the odd version now I think it's just temp 2 It might be uh it might be this.
I'm a little confused by this part.
It's confusing. Um, so the bound was three.
We said we're going to add from one to two, but we're going to exclude two.
And it's going to be the sum of odd values.
Huh?
Yeah. If we did the sum of the odd values like where two is the index of the odd value. So like 1 1 + 3 then it would be 2 ^2 which is 4. But it's it's not that it's the odd values that are bounded by this index. So like the odd values less than two for example or less than or equal to two which is a little bit more complex. the odd value the number of odd values that are less than or equal to some number let's say x it's going to be I think just divide by x so say temp modifier so this is going to be squared Um, but this is going to the number of odd values less than or equal to a certain less than or equal to temp which is going to be like one to one to two is just one value. So you could divide by two and that gives you that um three values though you so you would add one divide by two there's a lot involved here a lot of things going on here this is pretty messy I think you add one divide by two and then square that. So, uh, yeah.
So, for two, you add one to get to three, divide by two gets you back down to one, and then square 1 * 1 is one.
Um, for four, add one, divide by two gets you down to two, and then square two. So, 1 + 3 gives you four. Yeah. Okay. I think that's really uh, is this correct? I don't know. I guess we'll find out.
It might be just as it is. No.
Okay.
It's a rough one, huh?
How's Chad doing? What's up, Chad?
You're probably like, "You're on your own with this one, bud."
This is definitely um more challenging approach.
There's probably a much simpler way to do this, but uh this is one way of doing it.
Um, I'm very tempted to use like sliding window or something or like like a prefix summary or some something that just makes this a lot easier rather than trying to directly compute how many ways each element gets added.
Although it can be done, I think I'm sure there's a much better way to do this. It's a lot faster.
Excuse me.
I might be spending too much time on this quite frankly.
Um, all right.
So, I missed something here. Um on the first one I have this temp modifier here. Temp modified this rising count.
Um apparently this is off by by 10.
How many times does one get added?
do something deep here.
Um, come on.
I might want to put this on actually this way.
Okay.
Let's see what numbers I get here.
This 1 14253 case I should get.
So this is the total the number of times. So this is appears one three and five and one time each it should be three not one not two.
This is off by one. This appears uh once in the one case, twice in the three case and once in the five case.
So one, two, one.
Yeah, that's correct. Um so this is right. The second one, this two should appear once in the one case, three times in the three case.
Um and then once in the five case. So this should be a 1, three, and one. This should be five. So this should be three.
This should be five.
Um this should be once in the one case, twice in the three case, once in the one case, and then the last.
Yeah. So this should be 3, four, five, three.
Um, wonder if it's that simple.
Um, three, four, five, 4, three.
Um, Um.
Oops.
Trying to think about this here.
0 1 2 1 0.
I got to invert that.
If I did n minus be five, four, three, four, five.
Or do the other way around.
If I added this, I would get five, six, seven, and then I just need to subtract um 56765 minus two.
Okay. It's wrong, but it's close.
It's close.
It's not correct.
Uh, okay.
It might be as simple as this.
Oh, no.
Let me see in the in the three case it should be 10 gets added once and once and yeah one two three times it's one for one no twice one for one one for three is twice.
Um 11 is one for one, twice for two, one for three. So it's two, four, and two, I think.
Okay.
No, no, no. It's two, two, and two. It's two cross.
Each one gets added once for Yeah, it's it's just twice all the way across.
So, this is wrong.
Um, yeah, this is wrong. Okay, it's a fun idea, but it's not correct. A little bit little more complicated than that.
All right, let's go back to what I was doing then. Um, oh man, this is involved, huh?
Uh, let's see.
So, I said I said it should be 345 or rather I'm getting 242 again twice.
This one, this one's a little bit easier though. I think this is just one one.
Yeah. And this one should be two two across the board. Instead of getting one, two, one, it should just be getting 222.
Okay, so that means this should be slightly higher in these cases.
Um, okay.
All right. Uh the So the flat count for the first case should be I think it's going to be 11 one all the way across, right? One zero one 0 one something like that.
Um and then the rising count is just zero.
So we say the bound for I equals Z is one temp is zero. Yeah. So this rising count doesn't count at all for the first one. Um but the flat count is it's five minus this temp which we said is uh zero. So five. So it' be two fly count modifier is two.
which is not correct.
Um, it should I think it should be a plus one.
Oops.
Stream's still live.
See, just give it a moment.
Uh oh. Okay.
Um, yeah, I think that gets a plus one there.
That might be part of the issue there.
Oops.
Okay, there we go. A little bit better.
So now this is correct, but this one's not correct now.
So this should be a four, not a six.
Um, let me think. How does that handle? How does it handle? So it handles for says n - 10 + one. So uh this bound will be basically one temp will be zero. N - 0 + 1 / 2 is 3. Yeah, that's correct. One one three and five gives you three different odd values.
If we're even at six, you would get uh still get three, which is correct. Okay.
Um that's the correct flat count modifier for i equals z case when i equals 2.
Now you're doing 1, three, and five.
Um but in this case three is the only one that you would consider.
Um which is where this temp subtraction comes from.
So now n is basically like six and what do we subtract here? the uh this temp part the bound I think we said is two is one two subtract one is one multiply by two is twice oh it's confusing Yeah, it is confusing.
Oh my gosh.
Oh boy, this is getting complicated. Let me Maybe not start over, but remove some of this.
Let's just remove some of this. Kind of try to think about this a little bit differently.
I'd start over, but maybe take a fresh look at it.
Excuse me. All right, let's try this again. So, how many odd how many times is this going to show up in the odd cases? Well, it shows up once for one, once for three, once for five. In fact, when i equals zero and when i equals 5 towards the edges. So, we do we do want we do want this. This is going to be sort of near edge or I'm not sure what to call this. Um, we'll call this edge distance or distance Um that'll be the index and then sort of reversed as well.
So 012 and then 21.
Um there's some symmetry here.
Could even call it like sim symmetric index something like that. index.
All right. Um, now our symmetric index.
Uh, what I want to do is count the number of a times the i + one. So, we're going to say flat.
I guess the flat part of this calculation um that's how many times we multiply by i + one which is the sim index + one not the not i + one the sim index plus one okay um now the sim index + one I think that's what one of the things that changes here um in the odd case zero you get i + 1 at i = 1 you get it should be a two right three and three had in this case it's still three because the three amount reaches us three times but one and five only reach once so it is still a sim index plus one for the flat part. Um, and the number of times it occurs is going to be I guess it's going to be basically the number of times the number of the odd sized subarrays are going to be larger than the sim index.
Oh, really? Oh, really? The number times the sim index is larger than I'm not sure how to express that actually. Uh so the number of times the there's a lot of symmetry involved here.
It gets confusing.
The number of times the oddlength subarrays not only exceed the sim index value um I have to but also those arrays themselves modified should exceed the sim index. So for example like four and five should actually just count as two and one again which is confusing. So the symmetric version or the the reflected version, I'm not sure how to express that. It's like it's not uh it's not four and five compared to the sim index. It's one and two compared to the sim index.
And it should be exceeding greater than equal to the sim index plus one.
That's the flat number.
The number of times that those lengths are greater than equal to 7 x + one.
And those lengths are going to be um you could just extend it up to the midpoint and then multiply by two.
But yeah, those those lengths that it's going to be in this case, it's going to be one 31 for the odd ones, right? Because we exclude two and two.
So the num the numbers we're dealing with are 1 2 3 2 1. the number of times those numbers exceed greater than equal to three.
Yeah, that's really confusing. I don't even know how to explain that in English. Articulate that. Uh yeah, they're like symmetric versions of themselves.
Something like that.
Yes. So, calculating this flat portion definitely is not obvious.
It's not that hard, but it's definitely not obvious. So, So the number of times that array of elements let's say is greater than or equal to sim index plus one I think can be calculated in a in a a formulaic way but it's just not obvious how to do it. It's not immediately obvious. Um like I said in this case it's going to be 1 2 3 2 1 is going to be the the elements and the sim index ids sim index plus one values are also going to be 1 2 3 2 1 um so obviously the first time the number of times you exceed one oh n where don't include the the even value so it's 131 rather than 1 2 3 2 1 be 1 131 so the number of times we exceed one is three times number zero. Oh yeah.
Number times we exceed one is three times. Number of times we exceed two is once. Number of times we exceed or greater than equal to three is once. Um and the number not exceed but greater than equal to one. It's three times one time for two. One time for three, one time for two again and then three times for one again.
So it becomes 3113 is this flat amount which I think is correct by the way.
Yeah, that's really confusing.
This is really confusing.
Um, how can I encode? How can I compute this? Um, one, two, 3, two, one. So if it's an odd number that we're dealing with, let's suppose we remove it for the for the sake of argument because I can say we're just going to double the number of times. So we can split this into two components. Um to flat even and then odd portion odd portion.
If it's if it's even, we can just double this part, which is going to be um the number of odd numbers that are less than or equal to it' be sort of like n minus one or something.
Oh, what did I say it's going to be? So with five, the largest number you get is three, which is n + one by two.
That's the largest value you get.
computer is struggling here.
Um, but actually that's not the part that we're going to double. We're actually going to subtract one, I think, and divide by two instead.
If it's odd, that's if it's odd. If it's even, we don't need to subtract one.
Yeah. Four. The largest value is two.
Yeah. If it was it was four be 1 2 1 which is symmetric, right?
So I think we only subtract one if it's odd.
Um, and I don't think you need to subtract one if it's odd, by the way, because this will automatically when you bit shift it'll remove that.
Doesn't matter. Okay.
So now that gives me the upper bound on um the number of odd numbers.
Oh, this is peculiar, huh? Look at this.
Look at that, man.
Oh my gosh. Oh, you got to be kidding me.
Okay. So, it's the number of odd numbers.
How's stream doing by the way?
Okay.
So here you would have five / two gives you two and then I'm saying square that and bishop to the left. I don't think that's right by the way.
Um 5id by two is two.
Hold up. Um, I'm sorry it's really hard to focus. Um, give me a second.
There we go. Um, this is so confusing. I'm sorry. I'm also like distracted a little bit, too.
Um, all right.
This isn't the right one so far. Let me just you've got this symmetry, right? We're going to remove the odd part.
So we consider the largest value you can go up to is going to be two or five. So yeah, and n divided by n bit shifted to the right by by one is probably fine.
Um, and then what happens is we want the number of odd numbers that are less than or equal to this value two.
The number of odd numbers that are less than or equal to that value. So, let's just do uh standard helper is not so simple. Um that's going to be I think add one and bit shift by two again.
So the number of odd numbers that are less than or equal to two I think it's just one right. So you add one to three divide by two you get one about three.
Yeah. So then and then and then this odd helper squared this is the number of and then you shift that by two.
Oh yeah, that's really confusing.
It's so kind of ridiculous.
So yeah. Oh my gosh, man. Oh my goodness. Oh, okay.
I didn't choose the le code life. Le code life chose me.
I think that's correct. That's so messy, but I think it's correct. Uh, it's also make sure I have the right number of um All right.
So we're going to just consider the odd portion. So 5 / two is two. Uh counting the number of odd numbers that are less than or equal to two. We're going to add one and divide by two. And then you can square that number to get the sum of all those odd numbers. Okay?
And then this is the even part. Um, and this is the even helper actually.
Um, and then what's going to happen is, uh, we multiply that by two because it's on both sides, right? From left to right and right to left. We're adding that together.
Um that yields the flat even portion.
The flat odd portion I'm sure there's a way to optimize this.
By the way, somehow my computer is starting to struggle with this.
Um the flat odd portion I think is a lot simpler. It's just going to be um basically this n / 2 greater than equal to sub x + one.
Um I think it's like this.
So if it's five divided five becomes 6id by two is three.
Um six would still be three. 6 + 1id by two be three. Yeah.
Um this is yeah six would be zero one two three. Yeah. Yeah. It's just it's just the sim index portion. So um yeah, it's going to be n and one.
So this flat odd portion is just a check if this is if it's an odd sized array.
Then we're going to check if um if that point that we've removed exceeds the sim index or not. So sometimes we add this extra part and sometimes we don't.
Okay.
Um so that's the flat flat portion. Uh yeah.
Okay.
Um, now the rising portion.
All right.
Um, this is not going to be the sim index plus one.
This rising portion is a little more complex.
It's zero in this case. There's nothing rising there. In this case, it should be a one and it should be a one on both sides.
Um the three count has the sim index number. The five count only has a one.
That's part of the rising portion. So you multiply the rising portion by by two.
Um and yeah, my computer is struggling now.
I don't know why but it is struggling.
Uh now how would I compute this? Um it's very similar to what we just computed the flat count but It's It's a little different.
It's more like It's more like this flat even portion.
I wonder if that's correct.
I wonder if it's just this flat even portion.
That might be the same thing. I don't know.
That's confusing. Um, let's make this uh let's make this just without the multiplier there.
Oh, yeah. I don't I don't know what's going on, but the the browser is definitely having a really hard time.
The computer's having a hard time.
It might just be.
Could be a few things.
I suspect this rising count is is basically the same as this flat even portion.
It's the same thing. That's actually what I'm trying to calculate here.
By definition, I won't have the flat odd portion. I think it's just the same thing.
What happens if I do this? I think it's the same thing. I could be wrong, but compiler Uhoh.
Um, wrong answer.
581185. phone. No, that's much too large. Okay.
Oops.
Oh man, this is going to be rough, huh?
Have to keep that in mind for the future.
Sometimes the computer struggles lagging.
So flag count I got three which is correct.
Rising count should be zero.
Flat count is six. This is wrong. Fly count should be um one.
Okay. fly count's incorrectly computed as well as the rising count.
Both of those are wrong.
Okay, let's go back. Let's make sure the fly count's right. So, that's supposed to be one.
Oh no. Oh, I may have to cut the stream early. the computer's if it's going to keep doing that that's going to be kind of an issue or like basically like buffers the end. Um where was I?
Why don't you use DP programming? What's up uh Tahuain?
Howdy. Um I you know it's not a bad idea to try to use DP here. There's a couple reasons not to use DP. So one reason is that I think this can be done in linear time with constant memory.
If you use DP for this then you use extra memory. Um so I think there is a better solution that doesn't involve DP.
That's the first reason. Second reason is that I don't see the DP solution immediately. I have to think about it.
um the DP solution might be a lot faster to program like in if you had like time bounds then I would say using the DP solution in that case is probably best but the reason I'm not doing it in simple terms is that I think there's a way to do this that's more direct it's just not obvious um and I'm struggling to kind of formulate it correctly all right so the flat count at six at two. Yeah, at four should be six.
So, this was incorrect. Um, so I had five this even helper five / two is 2 + 1 is 3id 1id two is one.
So my even helper should be one and then the flat even portion I get 1 * 1 bit shifted by two is two and then I get this flat part is two plus something else. So this is wrong.
This should be a one.
Um yeah this is not quite right. Uh, it's even help us.
Um, I'm also kind of surprised because this Oh, right. Um, yeah.
So, this is um Um, I want to say this is more like sim index or something.
That might be where it's supposed to be.
And yeah, this is the lag is getting pretty intense.
I think it has to do with I might have to just refresh code or something.
Oh man, this is super awkward.
Um, no, that's not the I don't know what was I thinking before this flat count. This is wrong. It's definitely wrong. It's supposed to be 311 31113.
for the flat flat amount. The flat count and then the flat count is then multiplied by the sim index plus one.
This is wrong. This is very wrong.
Uh let me think about this for a minute.
Oh man, what did I do wrong there? Um, it's the number of oddlength subarrays that when I guess reflected, meaning uh you take the the length and you take n minus the length plus minus one I think so like 1 3 and 5 becomes 1 3 and 1 it should be so it would be I think it's n - i + 1 5 - 5 + 1 2 would be no it's n - i minus one no uh uh I think it's n minus i it should be 1 2 3 2 1 so one should be one that's the minimum of those two things of a minimum of i and n - i + 1 or n - i minus one so if i is 1 you get 5 - 1 - 1 is 3 should get one when i is 2 5 - 2 - 1 is 2 which is should be correct as two and then 3 5 - 3 - one.
No, that gives you one again. That should be three.
I think it's I think it might be + one.
Five. N - I + 1.
5 - 3 is 2 + 1 is three. Yeah. And then 5 - 4 + 1 is 2. 5 - 5 + 1 is one. Yeah.
Take the minimum. So, it's going to be the minimum of I and N - I + 1.
Um that's like the reflection that's happening and then where I I is the length of the subarray.
And then we're going to count the number of those reflect the subarrays. The subarrays that are odd and have a um a length that's you know reflected length. I'm not sure what the right word is for that. I'm calling reflective, but I'm not sure what the right right phrase is. Uh that's less than or equal to um the sim index plus one or excuse me, it's greater than or equal to sim index plus one.
Um interesting.
Okay.
Um All right, let's try this again.
depending on what the SIM index is.
And depending on what N is, it doesn't really matter as much what N is. It matters more what the SIM index is.
It's very confusing.
How many of those values are greater than equal to the sim index?
And then I'm going to double that. So that makes things more confusing, too.
Oh.
Oh, I'm making this so much more complicated than it needs to be, I think. Probably.
Um, gota think about it. Gota sit and think about it for a while.
I think I could just use the sim index plus one and then count the number of arrays that are greater than or equal to Right. Well, the the thing that makes that confusing is that the the arrays themselves also have that kind of symmetric property, which is why this is complex um or more complex. Uh let's just let's just remove the odd port part so that way we can just double the Yeah. Yeah. Okay. Okay.
That's what I did before.
is that we're going to remove the odd part al together and compute the even portion which is just going to be a doubling of um it's basically just like the send index with some modifications.
Excuse me. So also I think I got to refresh the page or something. Let me let me try that.
Let me try refreshing this. See what happens.
Hopefully that fixes whatever is going on here. It's starting to like really lag for some reason.
Um I'm not sure what the lag is from.
Uh yeah, it's not good.
I might I might need to I think I'm okay.
I think I might want to restart the stream because this is my browser is starting to crash here.
Yeah, this is a bit awkward. Okay, sorry folks.
I might just I might just need to restart. Yeah, this is really uh uh something's not right. All right, let me try to solve this question and then I think I'm going to restart afterwards because this is not quite um this is going much slower than it should.
All right. Um, see my think my thinking here is that the I've got to count for that sim index plus one which for five is going to be 1 2 3 2 1 um I've got to count the number of oddlength um subarrays that are greater than or equal to that particular sub index plus one and the number of those arrays and it's not just the oddlength arrays but this oddlength arrays modified suddenly they would be instead of 1 2 3 4 five it would be 1 2 3 2 1 and then if it's only the odd ones it's going to be 1 three and one so I've got to count in that way which is a little bit more complicated um so the way I decided to do this is exclude the sim index one plus one value that's going to be odd and count that separately.
Uh or the array value that's going to be odd.
Um which actually mirror the sim index mirrors the array values. So, it's really only if it's really only if I is uh is in the middle of the array. Quite frankly, it's the only time where this really gets complicated is when I is in the middle of the array.
So, we're just going to say if i equals um like if if n and one and i equals array size or n / one Just have to be careful because of this.
Then we're going to do something different. But other all the cases I think we don't I don't need to be that careful.
Okay.
So, in these cases, I actually don't need to care about that middle portion at all. Um, and so I can just say, uh, get the sim index, add one to it. um or sim value we'll call it.
So I don't really even need the sim index value or sim index itself. It's a symmetric value. Um and then I'm going to count the number of odd numbers there are which is going to be something like this.
number of odd numbers that are less than or equal to that sim value. So if the sim value is two, um the number of odd values that are less than or equal to oh yeah, that's right.
The number of odd values that are less than equal to two, it's going to be 2 + 1 divid by two is 1. And then number of odd values that are less than equal to 3, 3 + 1 divid 2 is 2.
which is right to get one and three.
Yeah. And then then the even helper squared. Um and then we double it as well to get the portion.
Um and then the flat odd portion we don't even need don't need that unless it's unless it's the uh Oops.
The flat count could put down here.
All right. Um, oh, excuse me. I forgot. Okay, my mistake.
Um yeah, I'm just gonna like to do come back to that.
Uh I think this flat even portion is correct.
Um we'll come back to the rising count later.
The flat count.
Yeah.
This should be something like this. Confusing. Uh what do I get for mix?
Okay.
Um, this is maybe a lot more time than is required for this question.
But it is um meaningful here.
I'm not going to commute these other parts here for now. We'll just leave this leave this as it is.
I'm just interested in the flat part for now.
Okay. I got 32.
All right. Uh should not be 32.
Uh this should be initially one.
Oh, that's fine.
Okay. Two.
It really should be three. The flat part there should be three initially.
Um.
Oh, I do have to add the odd portion, don't I?
It's so confusing. It's very confusing.
Yeah. Uh the I do need to have the odd portion. The reason the odd portion needs to be there is because this is the number of it's the number of subar odd subarray lengths that are slight they're modified so that way they reflect um like one two 321 rather than 1 2 3 4 5 that are greater than or equal to the sim value at that particular index.
Um, so the reason I still need this flat odd portion regardless of whether or not we're looking at the middle point is uh because I need to add that that three that's being counted.
That's pretty annoying. It's really annoying.
No. All right. Uh, yeah.
Okay.
Yeah. Three is always going to be greater than equal to the this odd portion will always be there.
It's always going to be greater than or equal to uh symbol.
So really this is just one to odd quite frankly.
Um, not assert or cast.
That's really annoying.
That's really annoying.
Yeah, it's just always going to be there, I think. Uh, there's no way around that.
Let's try again.
My gosh, man.
Flat is three. Okay, got it. But these other ones, flat should be one across the board.
So it should be 3111.
That's annoying.
3393. What is this?
This is wrong as well. So, it's not the number of odd values that are less than or equal to sim value. It's the number of odd values that are greater than or equal to sim value. So, it should be getting smaller, not larger. Uh, it's another mistake.
Oh, that's confusing very much. So, it did.
Okay.
Um, how do I calculate how many odd values are greater than equal? Greater than equal.
Uh, I could subtract. Could do it that way.
So, we're not going to multiply by two.
This flat even portion is going to be multiplied by two.
Um the even helper it's going to be so this is the number of odd values that are less than or equal to some value.
We want the number of odd numbers that are less than or equal to n.
minus the number of odd values that are less than or equal to the sub value.
And that gives me the number of odd numbers that are greater than the sub value.
Well, we want greater than or equal, not just greater. Um, and we also want if n is odd then we don't want to uh we don't want to count the larger value for n. So like if n is five we don't want to count three in there. We want to count just two odd values less than between you know less than equal to two rather than less than equal to three for reasons mentioned previously.
Very confusing. I know. Very involved.
Um, I'm going to charge my computer again.
Give me a minute.
Okay. All right. So, um, yeah, this also gives me values that are greater than the sim val, not greater than or equal to the sim val. So, I should actually subtract here.
Subtract one instead of add one. Okay, that's a little more what I'm looking for.
Complicated complicated.
Um, fly count is five. Okay, better. It should be one one 5115.
It's much closer. It should be 311.
That is much better. Um, maybe this is right then. Actually, there's a plus one.
No, no.
There's something slightly wrong here.
Okay. I know what's wrong.
I know what's wrong. Um, all right.
Okay. It's going to be this minus this.
Something like that.
Although with some slight variations I think.
No. Nine. No, it's too big.
Maybe this is plus one.
I don't think this I have to think this through a little bit more.
Oh boy.
No.
All right. So, this is a tough one.
Okay, let's try again.
We're going to say constant Um odd count one.
Odd count two.
And then this even helper is the difference between these two. Odd count one minus odd count two.
It's yeah odd sum one odd sum two.
Now, as I mentioned, the idea is that you've got a certain number of elements that you want to know how you want to count the number of those elements that are greater than or equal.
And these are odd. And actually, I don't need the sum of these. That's a mistake. That might be what I'm doing wrong here.
Excuse me. That might be a mistake.
I think I just need to count.
That might be one of the errors.
Yeah, I just need to count how many there are. I don't need to know the sum of those.
Okay, a little bit closer. Three. It should be 3113, not 33133.
Um so in this case five / two is two and then val of one.
Two / two is one. This should be 2 minus one is one. So even helper is one.
Multiply by two. This is odd at one. So it calculates it correctly for the first one. And the second value same thing and it's two symb um two one 2 - one is one.
Um I'm supposed to get zero for this one or one zero for the flat even portion.
That's a tough one, huh?
This is wrong. This is not supposed to be two. It's odd count one. I don't think it's odd count that one's ever supposed to be two. It's supposed to be 135 becomes 131.
Um, yeah.
This is supposed to be a one.
Yes.
If n is even, this ends up being n over two.
So six would be like one, two, three.
Number of odd values less than or equal to six.
Ah, it's really the number of odd values that are less than equal to three, which would be n / two.
I think divide by two again.
It's a little odd, but I think that's correct.
Okay. No.
Now one one negative one. Oh my gosh, dude.
This is like my gosh.
What's even going on?
What is even going on?
Number of odd values.
Oh my gosh.
Hold on a second. Let me think about this for a second. So I want the number of odd values that are less than or equal to n / two. If n is five, we get number of odd values less than or equal to two. n is six, number of odd values less than equal to three, which when you divide number of odd values less than equal to three.
So it's going to be + one two.
Yeah, confusing, but that's that's the right one.
Um, five divided by two is two. Number of odd values less than or equal to two is going to be 2 + 1 divid by two is 1.
3id 2 is 1. Number of odd values less than or equal to uh divid by 6 by two you get three. Number of odd values less than equal to three. 3 + 1 is four divid by two is two. You have one and three.
Yes, that's right. So there's the number of odd values that are less than equal to two.
Okay.
Then we want the number of odd values that are less than or equal to the sim value less than or equal to the sim value.
Um which should be actually some value this one.
And then we can take this difference.
I realize this is very confusing.
This is still wrong. Okay. Of course it is.
So brutal. It's so brutal. Oh my god.
It's a rough one. It's a rough one.
Let's try again. Um so for i is zero. we get the same value of one.
Number of odd values that are less than or equal to one should be one which is what we get.
Um this is less than or equal though we subtract one because we want don't want less than or equal. We want less than.
That's four because when we subtract on the other side odd count minus one minus two we want greater than equal not just greater than. Okay, there we go. Now it's correct. Oh, it took so long. Took so long. How many hours did that take? Oh my gosh.
Took like hours. It's brutal.
It's very brutal.
Um okay now uh the flat so that's the flat even portion counting the odd values and then the odd portion we add we just add so that gives us the flat amount okay finally that took took a while now the rising amount is a little more complex um that's going to be the uh we're not just counting the number of odd values now now we're taking the sum over those odd values and these are not going to be the odd values that are greater than or equal. These are going to be the odd values that are less than.
So now this is more like um this odd count um it's similar to this odd count odd count three.
Okay, this is going to be the number of um odd values that are less than or equal to the sim value which is going to be like this.
Um and this one can we compute a sum?
Now is it less than the sum value or less than or equal the sum value? I think it's less than the sum value. Not less than or equal. I think it's actually less than which would be the same thing as this odd count actually.
So it's actually odd count too.
Oops.
And then we square that odd count too to get the sum over those odd values.
Um and then Yeah. And those are we're not going to multiply by the same value by the way.
Fly count and rising count. We add those together.
Oh man.
Is that complicated or what?
Raw mount three flag count one oh no the fly count should be here should be oh yeah yeah this amount should be the rising count whoops did that wrong this is multiplied by two by the Okay. So now we get the right answer.
Finally.
Fly count three, rising count zero. Fly count one. Uh fly count. Yeah. Two. And the rising count is two.
Gives you mount four.
And then five. Three, four, five. Fly count three. Ro count two.
Uh, that gives you five.
Yeah, because even though it's a one, multiply by three.
to get three. And this other one's two.
Okay, so that one's computed correctly, but the other ones are not computed correctly, which is annoying.
Um, six. It should be three.
Flat amount is two.
the first one which I think is probably wrong.
Um it appears twice once in one and once in two.
So that's correct.
Rising count is zero. Flat count is Yeah, that's actually correct. It's two in mult both cases.
Um Um, wait. They said there should be three one. Oh, but it's odd. The odd the odd ones. Oh, I see. Um.
Oh, I see. I see. Um, in this case, you don't have 131. You just have one.
Oh, I see. Okay.
It would be like one, two, one, but the two and the one. Yeah. Okay. All right.
That's a little bit odd. Um, I think this works for cases that are larger than one and cases that are larger than one, one in three.
I didn't check what the test cases are.
That was one,000 only. Okay.
Oh, it's wrong in this case still. Oh, no.
H, it's a bummer.
Okay, so it's still wrong, but closer.
Um, I might want to take a minute to breathe here.
It's a tough one, man.
I could have just used the uh the more basic approach and just went straight through. But like the quadratic time solution, but I believe there is a linear time way to do this that's that doesn't use extra memory. Um, it's just a little bit involved.
Ah, that's a bummer. Okay, let's try to fix these smaller cases first and see where what I what happens.
So, okay.
We're not correct. Um it should be zero in this case.
Um okay.
So 2 / 1 is 1 + 1 is 2 / two is one. So I'll count one of one.
The sin value is zero. So this is this is wrong. Um why should the flat amount be zero here?
Uh the reason is it the reasons that the this wondering if this should always just be one.
You just always add this portion.
Excuse me.
I'm missing something important here.
So what I was suggesting was that in this test case um you have five three and one covers one once each time.
Actually, maybe that's easier is to just count the number of oddlength subarrays that um include this value.
One does.
Two does. Well, two does it twice.
Three does. Three does it three times.
Oh, no. Three does it twice.
Four does it twice. Five does it once.
That's kind of what I was trying to compute.
That there are like different ways you can understand this. I guess um Oh man, I mean it's so complicated.
simple way.
Just think about this. It makes a lot easier. Um, yeah, that's what I was trying to capture there with the flat portion was that like how many times does Do the arrays capture it more than once?
Um, yeah, it's kind of a wonky way to do it, quite frankly.
Uh, this gets captured once by size one and this gets captured once by size one and size two is just completely ignored.
So would that be considered the flat part or the rising part? Well, the rising part as I described the flat part basically is the peak where um the most the most subarrays cover that element.
Um so this one only one of them covers it three times.
This one is covered twice by three.
This is 3 1 3 1 3 times.
And this one it's covered by its maximum three times.
This is covered by its maximum, once, twice.
Oh no, but it's an odd number of times, right? Odd length numbers. So it's this is this value is covered by its maximum.
Three covers it twice and four covers it. No. And that's it.
Actually, just one time.
This is just once. And then this is um also once um this is covered by its maximum three times though.
All three lengths cover it.
What?
Okay.
Same thing on the other side.
Symmetric or mirrored.
Then what about uh what about um the other arrays? How many times those cover? So this is all three of the subarrays maximally, right? Times one.
This is the first subarray covers it once, right? Size one. The size three covers it twice and size five only covers it once.
So it's three, four, five, four, three.
This one it's just there's only one subarray that matters. It's just one side length one.
Um this one length one covers each one once.
Length three.
Oh, you know what? Actually, maybe I should use a sliding window approach.
Um, I don't think there's anything you need to do dynamic programming here though. I don't think so.
Let me let me see something here.
Let's Let's do some Let's do some things.
Okay, let's do like 10, 15, 20, 30, 23. It's just actually small numbers.
One, two, four, five, six, seven, eight.
Okay.
Length one. 1 + 2 + 5 + 8 + 9 like three. 1 + 2 + 3 + 2 + 3 + 5 Um 5 6 + 7 6 7 8 7 + 8 Okay.
Um, one, two, three, four, five. One, two, three, four. Yeah. And this gives me something like the following. 1 + 2 * 2 + 3 * 5 3 * 6 3 * 7 It's 2 * 8.
This is kind of what I'm trying to express here.
Um that you can calculate this number directly.
Um and then for five light five You get a very similar picture but one two three four five one two three four five one two three four five So you would you would go up to three.
So 1 * 1 + 2 * 2 + 3 * 5 + 3 * 6 3 * 7 3 * 8 + 1 * or 2 * 8.
Yeah, you got one, two, three, and then kind of stop at three.
And then these sums are going to be 1 + 1 + 1 * 1 + 2 * 2 * 2 + 2 + 2 * 2 + um 1 + 3 + 3 * 5.
Oh no, actually it starts off this is initially a one.
+ 1 + 3 + 3 * 6 1 + 3 * + 3 * 7 + 1 + 2 + 2 * 8 + 1 + 1 + 1 * 9.
So, this is kind of what I'm getting at.
Um, hopefully this makes some sense.
I really love how you tackle each and every problem. Yeah, I appreciate that.
Thank you. Yeah, absolutely. Deb Morer Desgupta, welcome. Yeah. Oh, yeah. I do everything. I do everyone, dude. I do every problem. Oh, yeah. I I do I do in the interest of time like sometimes skip problems a little bit, but like I try to go through everything. I like will eventually re return to problems if I have the time time for it. Um but I basically like to do everything. Yeah.
Um thanks. Thank you. That's that's a big I'll take that comp that's a big compliment. That's something I strive I strive for. So this is kind of what I'm getting at. Like I'm trying to visually understand like what these numbers are going to be in sequence.
Um, this is why I'm I'm saying that I think this has a pretty clear pattern.
It's not an obvious pattern, but it's a clear pattern. Um, like it's not not obvious what it is, or it obviously has a pattern, but it's not obvious what the pattern is. I'm not sure how to expl I'm not sure if it's clear or obvious which one it is, but there's a pattern for sure, but it's not so obvious what the pattern is. And this is what I'm trying to get at is that um independent of the numbers themselves, there's clearly a pattern that depends on n and the index that you're on on in this case it's 3, five, 7, and then seven repeats one, two, three times.
So maybe I can use that pattern um where it'll go from 3 5 7 and it'll probably if n is larger it'll keep going up to 9 11 etc. But just keep iterate chaining an odd by an odd amount.
Excuse me. Starting with three being I think basically n plus one divided by two.
Um, so n plus one divided by two is probably where it starts. And then you add two at each each element.
And then when you get to somewhere in the middle, then you start subtracting two. Then then it's then it stays the same. And then after a certain point, you start subtracting two.
I would Oh, how do I know how far this should go?
Um, and is it correct that I would add two at each point?
I don't think I add two at each point. I bet you it's a little more complex than that. So, let's do So, I said one, two, three, four, five. Oh, I actually I'm not quite right here.
There's actually six and seven here.
Yeah, I missed seven. There's one more element here that I'm missing.
Does very much start to look like Pascal's triangle, doesn't it?
Yes. So that's Yeah, I missed um seven. So we have one, three, five, and seven here.
So I forgot seven.
Knight seven repeats.
Um, that's also some of the symmetry that I was describing before too that like the the lengths like one three and five and seven are actually equivalent to each other. So you can just do one and three and then double it and you'll get the right the same answer.
Um, but this ends up being four 6 8.
But let's do something a little more complex. Let's do uh let's do Whoops.
Hopefully I can do this.
Did it work? Oh, it did. Okay, let's do um uh let's do let's do like this. X1, X2, X3 with X0, X4, X5, six, seven, X8.
One, two, three, four, five, six, seven, eight, nine. All right. Now, if I do nine elements, I'm going to get nine * 1 * x0.
Now, this is going to increase to I think 7 * 2 + 2 * x1, which is kind of what I was trying to capture before.
Um, yeah. And then this one is with the flat part. This is kind of what I was referring to with the flat part.
Um, this is going to be 5 * 3 I think + 2 x2.
Is that right? 5 * 3 + 2. Um, is that correct?
Well, how would I say there's going to be one, two, three, four? It's 1, three, five, 79.
Um, I'd expect a similar thing for 1357 as this pattern, then a nine there.
So, I was wrong. There's not going to be nine ones. So, it's going to be one, two, three, four, five ones. Not nine, five ones.
And then two of those ones are going to be relegative here.
And so I have three twos, not not five twos or not that many twos. And then I suspect I get something like this.
So is it right that I get this these three * 5? Yeah, I do 3 * 5 here and then length five.
Length five repeats I think length length three. Yeah, it repeats length three.
Let me see. Actually, I think uh um I think actually it's not going to be 3 * 2, it's going to be 3 * 3 here on length three.
Yeah. Interesting.
Oh, wait, wait, wait, wait, wait. So, that's confusing, right? Maybe I should go through it again.
I I don't quite have the pattern yet.
Okay, let's try this again.
Um, we're gonna say oops.
Scaldron kind of moves me all over the place here. So, X0, X1, X2, X7, X9, X8.
Um that's like the f the first one is looks like this.
The second one when you have three you have x0 x1 it's x2 then x1 x2 x3 x2 x3 x4 and we're just going to say dot dot dot Okay. And the result should be x0 * 1 2 * x1 3 * x2 3 * x3 2 3 * x4 x5 Um, three times X6 Excel draw kind of moves my cursor around in a way. It's a bit odd.
Eight. Um, interesting. So, length five is different from length three in this case.
Uh this is going to be so length seven repeats length three with * x0 + 2 * x1 3 * x2 x 3 3 * x4 3 * x5 + 3 * x6 * x7 + 1 * x8 Length nine repeats length one with x sub0 + x sub1 like that x sub 7. See, um, line five is going to be zero, 61. This is two, three, four, one, two, three, four, five.
+ x1 + x2 + x3 + x4 + x5 x2 + x3 x 64 x 65 x3 That was only four 6 x 6 + x7 which gives me 1 * x 0 + 2 * x1 + 3 * x 2 + 4 * x3 5 * x 4 + 5 * x5 5 * x6 + 5 * No, not x7. No, it goes back down to four.
X7 actually I think it goes down further. X8.
So it should actually go down to one here.
Two.
Three.
Okay.
So, this is kind of what I meant by the flat part was that this section where it's five, this other section um where it's three across.
This is kind of what I was referring to.
Um so, this is interesting, right? Um, so now the four things that we add together for one is going to be one across or no it's five. It's five things.
So x0 looks like that. X1 is going to be one, two, three, two, one.
I think uh that's length five, seven.
Um yeah, length five is peculiar.
Um so length nine and length one are both ones.
Length Um three and length seven are both um twos.
Um and lane five is interesting.
L five I think is also a two.
No, five. Yeah, on X1 it's a two.
Yeah, this flat part.
Um, on X2 things start to increase gets interesting. It's one, two, three, two, one.
Uh, X3 I think starts to get to be uh what is X3?
Length one. X3 is one plus uh X2 is 3, X3 is three.
on the next one.
That's length three and length five it's also x3 is four x x3 at length three I think it's three interesting Um okay.
And then X4 becomes 13531 and then starts to repeat.
Oh, this is incorrect.
This is a two.
Uh, something's wrong here.
Okay, we got one, two, three, four, five, six, seven, eight, nine. Okay. Um, this last one should be all once.
Actually, I think these are Yeah, something like this.
X1 is all twos.
Yeah, I think X1's all twos.
That means the this one's all twos also.
And what about this one?
These should mirror each other. X X2 and X6 mirror each other.
So that's a bit odd, right? I mean, that's quite quite the pattern going on there. So um is this correct is the question.
Let me try to double check this. So select one.
It's one one one or no.
One, two, three, four, five, six, seven, eight, nine.
Length three. It's one, two, three, three, three, three, three, two, one.
Length five. One, two, three, four, five, four, three, two, one.
One, two, three, four, five, six, seven, eight, nine.
And then this repeats, right?
Okay.
And then if we add those down, you get one, two, three, four, five, 1, 2, 2,2, 3, 1, 1, 3, 3, 3, 3, 1, 1, 1, 3, 4, 3, 1, 1, 3, 5, 3, 1, 1, 3, 4, 3, 1, 1, 3, 3, 2, 3, 1, and 1, 2, 2, Okay, that's the pattern. Um, now how can I compute that a little bit more directly?
Right, if that makes sense. Um, how could I uh, excuse me, way too far down. Um, how can I encode this in a more generalized pattern is the question. Um I mean these ones are obviously just n each time the ending ones. The middle ones are a little more complex. It's two multiplied by across three multiplied across.
But then there are these kind of it's sort of like this rising intersection that occurs.
Um like what does the pattern look like for um 10 and 11 or just 11?
So if we add in two more elements, right? Clearly we know what this these are going to look like.
Um but it's less obvious what the internal parts going to look like. So this will probably be very similar, right? Add three there.
This will go up to five and add five here.
This will go up to seven.
That's one, two, three, four, five, six, seven, eight, nine, 10, 11, 12, 13.
That's too many.
Um, hold on. One, two, three, four, five, 6, 7, 8, 9, 10, 11.
Um, one, two, three, four, five, six, seven.
I think this will go up to five.
The reason why I think this caps out at five, um, two, three, four, five, six, seven, eight.
Yeah. The reason why I think this just repeats at 11 is because like you add seven across. One, two, three, four, five, six, seven.
You can only I think I think you cap out at like four or something here, right? So, one, two, three, four, five, six, seven.
And then it'll be that one, two, three, four, five. Yeah, pickups out of five. I think I think it just repeats.
Um, which is a little bit odd. I wasn't expecting that, but that's probably what happens.
And and then these repetitive patterns repeat.
That's probably what occurs.
This one should be okay.
So then these end up being a similar pattern that we saw before.
Twos across, threes across, but then we have ones, threes, fours, threes, ones, and then ones, threes, fives, threes, and ones.
It's a weird pattern. It's a weird pattern. Whatever I was doing before, I don't think captures this pattern, by the way. I don't think so.
That is a strange pattern.
I think this is the right one.
Yeah, the cap is going to be the length minus whatever sequence you're working through.
plus one um and and minimum of the length itself and then and then that difference that just described which is n minus length + one. So in this case it's three right 11 - 9 + 1 is three and then in this case three would be the minimum of those two and then these values are just going to rise up to that cap and then stay there and then and then fall back down. And that's the that's the clear pattern that every sequence is going to follow. Um but then I've got a sum in the other direction across those sequences.
So even those those sequences have a very clear pattern, the sum across those sequences and the the cross-section of those sums of those sequences is not as obvious.
So it kind of bubbles up. It's like uh repeated ones, then repeated twos, then repeated threes, then some one three repeated fours, and then back down 31, and then 13, five, 3, one, and then this this part just repeats a few times, this middle part.
Um, and then and then you have the same sequence again. 1 3 4 3 1.
So, a bit odd. A bit odd. Um, yeah.
Interesting. Very interesting. Um, huh. Uh, I could take the previous value and and increment or decrement depending on where we're at. So, the first value starts off at n.
The next value we add n minus2.
The next value at n minus2 again.
Then the next value um it's n minus4 gets added. Then n minus 4 gets added again.
Then we repeat that value twice.
Then we subtract n minus4 and then subtract um n minus 4 again. Then subtract n minus 2 and then subtract n minus two again.
Okay.
Interesting.
So, what does that look like?
There's three sections.
The first section is going to be start off with n and we say okay um result plus equals um Let me uh let me put this up at the front so I can go back to my notes easily.
Okay. Starts out n equals one. Now we're going to add n minus 2.
Okay.
Um, yeah. Add n minus two.
Then we add n minus 2 again.
Okay. Oh no. Um it's value time array of I array of zero.
Then value times array of one.
Um array of two. So we have n minus two.
Then we add n minus 4.
So add n minus two. Start off with n add n minus two.
Add n minus two again.
Add n minus4 here.
Do that again.
Then maintain that one two more times.
Then subtract n - 2 n - 4 subtract what we just added and then subtract again.
and then subtract n minus 2 and do that again.
Uh, and that will give me zero through nine. It should be 10.
Uh, one, two, three, four, five, six, seven, eight, nine, 10, 11. Should be 11 things I had here.
um n. So we would do we would do n add n minus4 add n -4 or excuse me n minus two add n -2 add n -4 add n -4 leave it once leave it twice subtract n -4 subtract n -4 subtract um n minus 2 and then uh subtract n minus Um, one, two, three.
Once. One, two, three, four, five, six, seven, eight, nine, 10.
Um, I'm missing something here.
So, start with n. That's once.
Add one, add one, add one, add one. So it's + 1 + 2 + 3 + 4 5 6 subtract 1 7 subtract 2 8 subtract n subract 10 uh one two three four 5 6 7 8 9 10 0 1 2 3 4 Oh, that's what I'm stuck. I was going to say I was like, wait a minute.
Should have this fully described here.
Okay. Yeah, there we go. I was going to say I was like I think I did this right so far. So these are three different sections, right?
This one is the increase or kind of increasing section and then this is like the decreasing section.
Um yeah or non increasing.
So not changing decreasing.
Um this is for the n the n= 11 case. It looks like this.
Excuse me. So let's try to emulate this now. Let's do val I Z start with I and then we're going to add equals and there's this other value J starts off at zero so at two and we're going to plus J plus equals two Um, we're going to do that. Um, it's actually going to be in steps.
So, we actually repeat repeat J twice.
Um, so we're going to say something like this.
only when I is a certain value. So when I is even, we don't multiply by two.
Um we could do two minus or something like that.
Um, so if it's odd, um, how does this work? I might have to do the other way around. Something like this.
But when it's uh when I is odd that's when we want to J starts off at two right yeah so initially we don't touch J we don't touch the value and then we add and then I should be even I I should be odd We're going to increment now.
So that way when we iterate again um oh no no uh actually only when when it's when I is even again.
So if I is even 0 - 2 I think it's supposed to be the other way around.
When I is even, this will increment by two. When I is odd, this will increment by zero.
Okay? And then, so what's going to happen is we get uh initially we decrement the value by two.
Then um so it's just val of array of zero array of zero then decrement by two um because this is even or increment J by two no I I actually becomes odd after that so we don't increment increment J and then and And now when I is odd, we don't touch J.
It's a bit confusing. It's a bit confusing.
Uh let's do let's do it this way.
Actually, this is a little bit easier to think about.
There we go. Let's do it this way.
It's confusing. You want to modify value first before I apply it. Let's do it that way. So initially uh val increments by n flatly and j is zero and then we're going to we modify i zero and then now here let's do j first and then increment i and we can say when i is odd when i is even then this will add two. Okay.
So now we add two to J add N minus 2 I is now one. We do perform this routine done.
Um now J doesn't change. I increments to two. Perform this routine. So we subtract two again from J. I is now even at uh three I think.
Uh oh no no um at yeah when I is two before it increments we add this again we have four i is three. Okay so this this is this will work. Um but now we get to five. So that's when I is less than four, less than or equal to four, we want to do these routines.
Um, what's interesting about this is we'll come back to that.
There's now this next set of things which is I is greater than equal to five and I is less than or equal to six.
Um increment I and just say result plus equals value times array of I.
Right? That handles these cases.
And then finally the mirrored version of this is going to be the decreasing part.
I is greater than equal to 7 and I is less than equal to the array of size.
So we're going to use this for the rest of the way.
Um so now it's subtract n minus j and here um j starts off exactly where it was before at four.
Um, and I at this point is seven and we would apply n minus 4 to seven and then j we want to increment now or decrement now actually um when i is seven this doesn't change. So yeah, this gets applied twice. Doesn't change until you see eight and then decrements again until you get to 9 10 and then we're done. And that's it.
Um, and that works for the 11 case.
That's exactly correct for the 11 11 case. I suspect this is correct for all the cases quite frankly.
Um if I just modify I so here this went from 0 1 2 3 4 which is the fifth element um first five elements then we had two elements where it didn't change um and then the last I guess five elements or last four elements I suppose.
Um, interesting.
So, how do I know what this should be?
Well, compared to 11, this is like 11 / two would be five. Be like less than 11 by two. Less than nid by two.
and then be greater than or equal to n /2.
Um I think this is only three elements quite frankly in the middle typically one to three elements.
Um, let's look at 13 so I have an idea better sense of things. What happens with 13?
What's chat doing?
What's up, chat?
What's up, chat? Uh, okay. 13 is going to be a copy of So here we'll add another two elements.
By the way, I didn't cover what this looks like for the even cases. I think it's very similar.
I suspect it's a very similar thing.
For three, it's just going to be this.
Actually, I should just copy this for this is going to be 11.
What happened?
Uh, I should probably just do that.
Okay. Um, five. One, two, three, four, five. Five repeated.
This will be the same for Seven or nine.
And then seven is going to be 1, two, three, four, five, six, seven.
Um, 64 32 8 9 10 11 12 13. Yeah. So this is going to be this this sequence. Um so again n minus 2 add n - 2 add n minus 2 again add n -4 add n -4 again and then add n - 6 add - 6 again n - 6 again and then you would have um ah okay I see the problem and then you would have um subtract n - 6 subtract n - 6 again etc. So actually there is no middle section. What happens is um this basically just uh becomes zero and and the n the j becomes equal to n.
you just you're just subtracting uh you're just subtracting twice uh n minus n. That's what's going on here.
So this is indeed um I of uh so in this case it would be 0 one two three or no no um it's going to be 0 one two three four five six I think all the way up to I equals um in fact I think you actually just go you're not subtracting n minus this thing anymore.
I actually think I think this just goes all the way through.
Yeah, I actually think this is just all the way through.
I could be wrong about this, but this might just be all the way.
It might just be that simple. I don't know.
Oh, okay. Maybe not.
Not quite. Uh, that's funny. Um, whoops.
Uh oh.
What did I do?
Uhhuh.
Interesting.
Uhoh. Uhoh.
Huh?
What?
Can make this a long long.
I did something wrong.
But it might just be that um this value starts to exceed N at some point like the J start to exceed N.
And actually uh wait what what's going on here?
Oh, not less than a repo. Duh. That's my fault.
I was like, "Wait, I did something wrong here."
150. That's not right.
That's not right.
These are way, way too large, huh?
These are way too large.
Um, Oh, it's not n, by the way. That's a mistake. It's It's n divided by two. 1 2 3 4 five 6 7.
Yeah, it's like n plus one divided by two.
And if it was 14, it would be two. Or no, if it was if length was if the if n was 14, it would still be seven. Length is 13, it's seven.
Say add one by two and um say we'll just say odd odd lengths.
That may have had something to do with it.
Okay, it's closer. Uh, it's wrong in the even cases though.
Whoops.
uh in the even cases it's wrong.
Let's do the fourth the four case.
Okay.
I was close, man. I was close.
seem to have figured out the pattern when it's odd at least.
All right, let's go even. So in the four case, length one and three.
I think it's just this um you sum all four and the three case it looks like this.
Yeah, that's a little different.
Uhhuh.
It is different.
Give it one moment.
Okay.
All right. Um the even cases are different.
That was so close, man. That was so close.
Okay. All right. Length one, length five.
This is if you have six.
Okay.
That's one, two, three, two, one.
Uh, all right. Definitely one, two, three.
So the third value one the first one two three has the third value in it. Second one has the third value on it and the third one has the third value and then it it's kept at three. So it's repeats and this one is so that pattern I just showed you is only for the that's only for Hi. What's up uh Yashinda? Oops. Hope your day is going well. Welcome welcome howdy. So we're investigating right now how I could solve this question sum of all oddlength subarrays um in linear time but also linear memory meaning we're going to do it without using dynamic programming and I think there's a way to do it but I've been struggling to get it right. So I think I got the odd case. Um but I don't think I got the uh the even when you have an even number of elements.
Looks like the odd case is right, but the even case is is not doesn't work the same way. So I'm investigating the pattern for the even case. See if I can find out what that pattern is.
using pattern recognition. Pattern recognition to see uh if I can figure out what the pattern is for uh for the even case.
All right, here we go. So in the even case, four elements. This is more of what what the pattern looks like. We add this is like if it was X0 I probably should put that at the top actually. So used to doing at the bottom. I don't I don't typically use Excal for my notes. I use a different program. Typically, I should write a notes program or something. Just write something for myself. That way, I just always have it available.
I could open source it and then people can use it. It's like notepad, I guess, but more for my use cases, I guess. I don't know. Sky Draw is pretty good, though.
Just isn't quite what I want to. It doesn't quite flow the way I'd like it to flow, I guess. I don't know. like it adapts to it. Um anyway, but so if this was like x0, x1, x2, x3, right? When we're looking at length one subarrays, we would be adding each of these one time, right? So one, one, two, three, four.
But for length three subarrays, we'd add one, two, three here. And then we're adding one, two, three there. So we would have this one twice and this one twice. That's why I have one, two, two.
This pattern is not the same as the odd pattern that I had before. The odd pattern that I had before is a little different.
Um, in the case of six elements, the pattern looks more like this. So in the odd case, so the odd the first one length one, length three, we would have one, two, three, back down to 3, two, one, and then length five actually repeats that um it would be length five, one, two, three, four, five, and then one, two, three, four, five.
Uh, it actually is not this pattern.
This is wrong. It's this pattern.
That was wrong. Um, one, two, three here. One, two, three here. So, X1 has two. And then one, two, three again. X2 has three, but also X3 has three because it's at the tail end of this one. And it's in the middle of this one.
And then X4. Similarly, it's included here and it's included here and nowhere else.
So, actually the pattern a little more complex little more complex than the other pattern.
So, I got to figure out what that pattern is. So, I think what I can do is say do the following.
Don't need this.
This doesn't need to be a long long. I thought it needed to be because I was accident I I made a mistake and I was I was um I made a mistake and I was adding uh like uninitialized memory with this with an equals there which is bad. Um but this is going to be if uh array size and one Then we're going to do this.
Um otherwise we're going to do a different pattern.
In the even case pattern looks a little more complex. So it looks like it look let me also check the stream health just to make sure stream is okay. Um looks all right.
All right. Um in the even case it looks like I start with n similar to the previous uh pattern where n is uh I say n but it's it's really this odd lengths value which I think is the same. So when n is when n when the size is four size is four divide by add one divide by two and you get two. When size is six add one divid by two you still get three. Yeah it's fine. So I get that's this is the right odd lengths amount. So we start by adding odd lengths which is fine.
But then we add it looks like odd lengths minus one rather than minus two.
Okay.
Yeah.
So J + equals 1 rather than two.
And And then oops.
Oh.
Um, looks like we subtract one initially and then I think we subtract one again from J.
Uh, yeah. Which There's the one there.
And subtract another one because we're only going to improve here.
Um, and then subtract another one to Yeah. And then just keep subtracting.
So, just subtract one the whole way through. Uh, okay.
I don't know about that one, but I try that.
It doesn't seem correct. Oh, that's right. Okay. There you go.
There you go. There's your pattern.
Tada. I did it. Tada. All right. I'm going to go for it. That's probably correct if it works on those cases.
Hey, there we go. Beautiful. I like that. How you like that? Hey, we did it.
Spent hours on that. Oh my gosh. Oh, so unnecessary. But there you go. They asked for a linear time solution. So, we got linear time and no extra memory.
Tada. Tada.
That was a little gross. That was a little gross. I wouldn't recommend that.
That's like This is like when you want to do research, this is the kind of thing you do. You just tinker with stuff until you find a pattern that you can exploit.
That's how you do research, man. That's how how it works.
Tinkering until you find exploitable pattern, which doesn't sound great when you phrase it that way, but say a useful pattern. Exploitable pattern.
Exploitation. Um, no.
Uh yeah. Okay. It's just satisfying to submit it a bunch of times. I spent so much time on that. It was so unnecessary to spend so much time.
It was interesting though. I mean, we learned something. I don't know what we learned exactly. We learned that uh yes, this does have a pattern. Yes, that can be useful. Yes, it can be done in in linear time. Yes, it can be done without with constant extra memory. Uh yes, it's a bit complicated.
Yes, it does simplify to something that's actually not too bad. Um, and yes, it will take basically research time to figure all that out. Uh, I don't know how valuable all that information is, but uh I guess it's something. I don't know. I don't know what to say, man. I don't know what to say about this, man.
Um, that was fun. I guess that was fun.
That's how I got there.
Sweet. I don't know. What do I do now? I just keep going. Um, I feel like I should take a break. Oh, how's the stream doing? Stream is Let's see. Is it still live? Stream might not up anymore. I feel like I should take a break. Oh, how's the stream doing? Stream is I think it says the stream is um Okay, there we go. It's back. I was going to say it says the stream is uh post buffering. Um, so there we go. We got the got that answer, man. Got there.
Do one more.
Oh, satisfying. Very satisfying. Um, okay.
Wasn't really necessary to do all that, but we we we did it. We did it. We did it. Uh, all right.
Okay.
We'll do one more question, I think, and then maybe I'll take a break. I was going to do an eight hour stream, but I I kind of like I don't know, man. That was that was a bit much. That was a bit much. Let's do one more and I'll think about what to do after that. Zero index integer array nums of length n integer k return the number of pairs uh 0 less than equal to i less than j less than n such that nums of i equals nums of j and i * j is divisible by k.
Okay. the number of pairs. That's my All right.
Okay. Well, this isn't that hard, right?
Um, basically, uh, any number that's divisible by K, all of the numbers to the right um, can be paired off with K.
And you can do left to right. So you don't need to go backwards at all. Um, yeah. So that's that's the easiest way to do that.
So you can just do something like the following.
Um, it's going to be nums of i mod k 0 times uh nums size minus i possibly plus one something like this.
Um like if you pick the third if you pick the let's say the first element it's going to be paired up with every other element uh except for itself right oh wait oh nums of i equals nums of j oh hold on a second oh no that's a little bit different um never mind so I did that All right.
Okay.
How big are these numbers? Oh, it's a little bit. It's a different approach I need to take. Okay, they're between less than 100. So, I can use a frequency map.
We're going to use a frequency map to do this. I did this. I got the wrong answer. Sorry about that. I misunderstood.
I misunderstood.
Um we'll come back to that explain.
All right. Uh actually it's a little different. So frequency of I nums of I and it's actually going to be nums of I mod K= 0 times might be a little bit easier actually I think it's this one is the way to do it. This is a bit of an odd problem.
Wrong. Okay. I misunderstood.
This one's correct. It's wrong.
A2.
So it has to be Yeah. So basically I'm looking at the values previously. So when I see three and three that should be one saying expected four. when I see one and one um that's not divisible by two, two and two. So the first two there aren't any previously so we add zero. This two and two we should add one and then this two and two we should add two.
Um, so it should be 1 plus 2 plus 3.
Uh, why am I getting the wrong answer?
Shouldn't I get the right answer?
Shouldn't this give me four?
Um frequency of nums of I which should be say when you see two it should be zero when you see the next two there should be a one there. So you add one and then frequency becomes two. See this you add another two and this adds zero. This adds one.
Yeah, it should be four. I get three.
Unless there's something going on here.
I don't realize what what's going on here.
What's going on here?
So it should be 0 0 1 3.
Okay, that's good. 1 three and then 0 0 1 3 3 4.
Oh, those aren't divisible by two either.
Oh.
Oh, why is this four Wait, what?
Four pairs.
Oh, if it's zero. Wait, what?
Oh, I'm sorry. That's I think I do need to take a break.
My brain, dude.
My brain, man.
Oh my gosh.
Oh my goodness. I didn't even realize it's I time I times J is okay. Oh boy.
Yeah, I need a break. I need a break.
It's a mixture of going too quickly and also not uh really thinking it through, reading it, reading the problem. It's good to solve the actual problem that's being asked. Oh my god.
Uh yeah. Okay. Uh, interesting.
This actually is pretty close, but it's um, okay, I think I could still use a frequency map. Frequency map, but I need I times J is divisible by K.
So, as long as one of these is to this one by K.
Yeah, it doesn't matter if they're Yeah, actually it's just I mod K.
I think one small change and this works.
Maybe this actually might be that simple of a change.
No.
Nope.
Not what I expected for.
Um, no.
Nope.
Okay.
Uh, interesting.
Doesn't quite work like that, unfortunately.
Yeah. The problem with this is that uh no, this approach doesn't really work in this case. It's wrong because I've already passed three like it this three could be paired up with all the other threes.
um could do it a different way. How about I just take all the ones that are um I could maybe do two passes.
Um I mean Uh I'm wondering if I could do a double pass.
Well, I mean, I could double count all the pairs, right? I could do I, J, and JI.
Um, if I just count all of the if I get just get the frequency of of values, for example, the frequency of two is a three. And then I just say um oh no it's not it's not yeah let's just get the frequency of all these values right and then I go left to right for each value that's divisible by k I pair that off with all the other ones so you know 2 minus one be one and then when I went over this way um I wouldn't count it again.
No, that's not correct.
Excuse me. That's not correct.
I'd have to get the frequency of things that are divisible by K and things that are not divisible by K or the indices are divisible, the indices are not. Um because it's going to be the indices that are divisible.
I would do um like two choose those indices and then the indices that are not divisible uh I would need to pair them off which I would do a I would just multiply those two.
Yeah.
Okay. That's fine. That works too.
Uh, okay. Frequency divis frequency divisible and not frequency.
Let's go with this one.
I can make these static. Static.
I don't know if that really matters, but we're going to do that anyway.
So for each number we're going to say frequency divisible const check is I mod k= z and then we're going to say frequency of nums of i.
Let's see. Let's check it's divisible.
Not minus equals check or plus equals check. It's not or not check.
Um and then we're going to say for in zero less than 100.
um results plus equals uh I mod. So again, cost check.
Um I mod.
Oh no, that doesn't matter.
Frequency of divisible I times frequency I + one shift one. So pair those off and then the other one will not be paired. Just multiply.
I think that's it. Something like that.
I'm going to go for that. See how that goes.
Hey bro, how are you? What's up? Devote of Radarani.
Welcome. Howdy. Hello. Hello. Doing well man. Thank you for asking. Doing some lee code over here. Apparently getting it wrong though.
No.
Oh no. What did I do?
What happened here? Uh oh. Uhhuh.
Wow. Um, interesting.
Uh, I don't know what I did wrong. Uh oh.
Uh oh. Oh, I might have been in choose too. I might have not. Yeah, that's a mistake. That might have been the mistake.
There we go. Got it. Okay, I think that's it. I'm going to submit this one.
That's a relatively efficient solution.
It's an okay one.
Oh, what's wrong, though?
No.
Oh man, that's a bummer. All right.
Almost efficient and wrong. And wrong. It's always good.
Oh boy. Oh boy.
Tisk. Tisk. Tisk.
Uh.
Okay. Let's see.
Huh. Output five expected eight.
Interesting.
All right, let's see if we can get those pairs. Um, now mind you, this could be done in quadratic time efficiently because there's only 100 question 100 uh integers, but part of me thinks this could be done with a frequency map uh a little bit faster. So that's why I'm trying to do that. But uh 0 1 2 3 4 5 6 7 8 9 10 11 12 13 elements. 1 2 3 4 5 6 7 8 9 10 11 12 13. 13 elements means there's only three elements here that are divisible by four.
Three indices, but they can be paired off with quite a few other things. But there's only one nine and one other nine.
So two nines.
Um which the second nine the second nine is actually in the uh in the no zero one two three four zero one two three four and the second is not. So I pair those two off. That gives me um one pair.
It says they're looking for eight pairs.
Four, five, six, seven, eight. Okay, this three could be paired off with one, two, three, four things.
uh I would get 1 + 3 is four and then one more would give me five which is 0 1 2 3 4 5 6 7 8 9 10 11 12 There's nothing to be paired off with a one.
There's only one one here.
I * J is by K has zero indexed.
Huh? 0 1 2 3 4 nine. Only one of the nine.
So that's a and that happens to be a pair. That's a pair. Then there's one, two, three, four threes.
012 two three four five Oh, I did it wrong.
Oh, I did it wrong.
I didn't think about um when K itself has divisor and you multiply I and J together and it's divisible.
I thought I could just Ah, that's a mistake on my part. Yeah, there more pairs.
Also, my calculation was wrong anyway.
Um, somehow it shouldn't have been. Oh, I guess it was five. I guess zero, one, two, three, four, five, six, seven, eight, nine.
I think the eight here we get one, two, three.
I don't know why I got five. I think I was supposed to only get four there. But anyway, I don't think my algorithm was correct.
Like I don't think my implementation of what I was trying to do is correct anyway. But also, uh, I did not consider when K is a composite.
That's a mistake on my part.
That's a mistake on my part. Um, okay.
Uh, I mean, yeah, that's that's a tricky one.
All right, we're just gonna we're just going to go with the the normal. I don't I don't think it's that obvious whether or not this has a faster approach. That was a mistake on my part. We're just going to go with the standard approach.
straightforward approach.
Um Yeah, given the constraints, this is fine.
Um, I think this will work. I might need some need some things in here.
Okay, what? Um, I would put these in here just to clarify things.
Yeah. Uh, given the constraints, this works. But if it was if the constraints were a little more complex, then this may not work so well.
Dang, man. Dang.
Yeah. All right. I said I was going to take a break after this, but that that kind of I'm not so sure about about this one. Let's see.
Um, okay. Yeah, I think uh I think uh I just kind of feel bad now.
Feel bad for trying to get the get a a better solution that was probably not correct. Uh it's awkward. Um, I mean, okay, you know, all right, given the constraints, this is this is a reasonable solution. So, we'll go we'll go with the next question. We'll go one more. We'll go one more. Um, and then I think I'll take a break.
That one wasn't too satisfying.
Yeah, it was a bummer. Not a bummer, but like not great that I uh submitted an incorrect solution there. There was a biker going on a road trip. The road trip consists of n plus1 points at different altitudes. The biker starts his trip on point zero with altitude equal to zero. Uh you given integer array gain of length n where gain of i is the net gain and altitude between points i and i + 1 for all zero less than equal to i less than n. Return the highest altitude of a point.
Okay. Uh going on trip road trip consist of some points at different altitudes.
It's true at point zero altitudes equals zero. Integer array gain of length M gain is the net gain altitude between points I and I + one. Okay, the highest altitude.
Um I'm not sure if we can do this in better than linear time.
Yeah, I think this is just we'll see.
I don't know. I think this is probably a relatively straightforward thing.
Is this I don't know. This is all I need.
I'm not sure if this is what they're looking for.
Just pretty simple.
Maybe this could be done like in simpler way, but I don't or a more um what do they call that?
Could be done in a more concise way. I don't know.
Um I mean, all right.
Okay, that one. I don't know what to say about that one, man. I don't know. That one's definitely a little bit easier. Well, these are all relatively easy. I think depends on how you try to solve them, right?
Positive integer n. Find the pivot integer x such that the sum of all elements between one and x inclusively equals the sum of all elements between x and n inclusively.
Uh interesting. So basically the the left side and the right side but not it's not pivot integer. It's um I think or it's not the left side the right side or equal. It's the I think it's every element that's smaller.
Unless X is an index. n is eight up six.
Oh no.
Oh excuse me. Oh I see. Oh, interesting.
I think you can figure out this uh mathematically at most one pivot.
Okay. Um Oh, interesting. Okay.
So, this is a math thing, I think. Um, if you do, uh, let's just make sure the stream is still live. It's okay. Yeah. Okay. Um, so, so this would be one to n, right?
Uh, we're going to say one to x x + one to n. They should be equal to each other.
um more precise notational I'll put down in a second but it's okay equals x10 inclusively okay so it's going to be it's not x plus one it's inclusive both sides so this is kind of like uh sum I actually didn't realize that one x is sum of x to n which this sum is sum is um is x * x + 1 / 2. And that's going to be the sum n * n + one / 2 minus the sum from 1 one to n minus the sum from 1 to x - one which is x -1 * x / 2.
So that gives you um x * x + 1 / 2 plus uh x * x -1 / 2 = n * n + 1 2 can multiply everything by two to get x * x + 1 + x * x -1 nus this one. That gives you x uh * x + one plus um x - one n * x - 1.
That gives you x * uh 2x = n * 1.
Um, which then gives you x = x^2 * x^2 + 1 x is =<unk> of n * n + one.
Yeah.
Um okay.
Turn static cast int square root and one.
basically that um there might be I think yeah it should be a negative one in some cases though um it's not that easy to check if a number is a perfect square however um Um, probably the easiest way to do this is in salt.
So we have this number and then we say um 2 * result times result equals um n times one say if bit shift if and this is equal or it's not equal.
Otherwise returns.
There we go. Simple.
There we go. I think that works.
Yeah. So, that's not a bad one either.
I'm not sure it's exactly constant time, but it's it's relatively efficient.
It's a relatively efficient solution.
That's probably a good one to end end on for the take oh, not end on, but take a break. Um I was going to go I was going to go for a full eight hours, but um some of those questions took a really long time.
Delete node a link list. This is a complex one or involved one. Um, this one is I already solved it, so I'm not going to do it again. But this is one of those questions that um it's kind of involved.
Um, okay. They said it's not going to be a tail node and so you can so about two million accepted. Holy smokes.
Oh gosh, it's a lot of a lot of people.
Holy Jesus. Holy smokes.
That's a lot of people.
All right. Uh given the node to be deleted cannot be given access to the first node ahead.
All the values link list are unique.
Given node node is not the last node to link the given node do not mean or mean removing it from memory should not exist in link list number of nodes link list should decreased by one all the values before node should be in the same order input we should provide the entire link list head and the node to be given node node should not be the last node in the list it should be an actual node in the list build the link list and pass the node to your function And the output will be the entire list after the function.
Um unfortunately uh you need the the node in front of this one, the previous node to do this efficiently. Otherwise, you basically need to like traverse the the list until you find your node, which is kind of a bummer, but it's not the worst thing in the world. Um, yeah. And then you just do a normal delete, which is basically just put the uh the previous nodes next um pointer to the deleting nodes next.
little bit involved but not the worst. And then and then you want to take that node and then point it to some point it to a null pointer and then delete it. Delete it from remove from memory. Um but do you get the head node?
You will not be given access the first node of head.
What?
Somehow I already solved this. I don't know.
Oh, I see.
Uh, interesting.
Well, I mean the other way of doing this, which is a bit wonky, but you can is um so the node that you want to delete, let's say it's five, you could just take all the values that come after it and just shift them over.
I wouldn't recommend doing and then just delete the last node, the the tail. Oh, that's why it's not it's not going to be a tail node.
is because you wouldn't be able to delete the tail.
So, you could do that, too. I mean, that's a bit awkward and weird, but yeah, you could do that. You can just cycle all the values back and then delete the tail node.
It's kind of obnoxious, but yeah, it's fine.
And then and then the tail node you can delete the memory. So yeah, I don't know how I solved this in the past.
probably I did in Python in March, but uh oh to 2019 some time ago.
I think I basically I suspect I may have cheated.
Oh no, no, I did exactly that. I uh Oh, wait.
What did I do?
I don't even remember doing this.
I said the node value is going to be next. Next, and then the node next.
Oh, that's clever. Oh.
Oh, I see what I did.
No, man. Don't cycle all the values.
Just just move the value. Oh, that's smart. So, just take the next node's value, save it in this node, and delete the next node.
Ah, that's funny. I didn't even think of that. That's even better.
Oh jeez.
There you go.
That's a fun one. Okay, so that's that one.
That's kind of goofy, but yeah, it's okay. Don't No, don't cycle all the other values back. Just just save the value that's next to it and then delete that node.
Uh, it's funny. Okay, got it. Got it.
We'll do one more one more question then we'll then we'll take a break.
All right. Arithmetic subarrays. A sequence of numbers is called arithmetic if it consists of at least two elements and the difference between every two consecutive elements is the same. More formally, a sequence S is arithmetic if and only if S of I + 1 - S I is equal to S sub 1 - S0 for all n I. Okay, arithmetic sequences. All right, these are arithmetic sequences. The following sequences, not arithmetic. You're given an array of n integers, nums and two arrays of m integers each l and r presenting the m range queries for the i queries. The range in the range l all the arrays of zero are zero indexed return a list of boolean elements answer where answer y is true if the subarray nums of l i l i + one etc can be rearranged to form an arithmetic sequence and false elements that's confusing um what are the bounds in this uh n numbers m is length m r length five n is 500. M is 500. Ly R Y is less than N numbers between 10,000 10,000 100,000 100,000. Um I don't know what I'm even looking at here. Uh uh arithmetic consists of at least two elements. Okay, got that.
Um so these are sequences array of integers and two arrays of M and M integers each L and R the M range queries.
Okay, so we got range queries. I query that range. All the arrays are zero indexed. Return a list of boolean elements answer or answer Y is true if the subarray nums L Y to nums R Y can be rearranged to form an arithmetic sequence and false.
Okay. Well, that's peculiar, huh? Um I mean probably the easiest thing is to sort it and then check the sequence directly.
Um there might be a more efficient way to do this but that's like the simplest way to do this.
Give me 654 to the sequence.
4569 cannot 3579 can be arranged.
Huh.
Um, I don't know if there's a more efficient way to do this. This is a bit bit of a complex kind of a thing task to do. Um, you maybe can use like a square root decomposition. Throw that somewhere in here to make things more efficient. I'm not sure where exactly or how, but that's like my best guess is that uh maybe a square root demp somewhere in here and then otherwise um I wouldn't really know how exactly and then maybe using hashmaps or something but probably the simplest approach is just for each query sort that range and then um check if that's an arithmetic sequence and time linear of the range.
That's probably the simplest way to do it. Um the number of queries is uh only about 500 queries. The number of numbers is uh only about 500 numbers. So 500 squared is manageable. So we'll just we'll just go with that. We'll just keep it simple and go with that. Um I think doing something beyond that it's unnecessary for the constraints. It's also like might be really complicated if it's even possible. Um yeah I think the other the other question that I was working on where I was like oh I'm not really sure how I could do this.
Everything you work on probably could throw a square root decomp in there somewhere, but the simplest thing is probably just um copying the numbers and sorting them. Um so int i zus i constant um left i.
write is ry um then we'll just say sto vector inte of nums begin left nin right sort in uh we'll just say is arithic take vector say if need signs This two false um constant diff it's going to be uh v1 z i z. It really should be i is one. I is less than um i + one is less than size.
true.
Um if v of i + 1 minus d of i yeah uh is not equal to diff.
Okay. Um vector B result of it's going to be L size and just say result equals this arithmetic.
In this case, I just copy paste just copied the the vector into a into a sub sub vector and then sorted it. I checked it that way.
It's so wrong. It's so wrong.
Um 0 to two should be true. Four five six is true.
Um 0 to three. 0 1 2 3 4 5 69 should be false. I got true for some reason.
Uh this might be a plus one over here.
And I might have made a mistake on that.
Uh should be true at the end. I got false.
012 345 3579.
Um, hold on.
What is going on here?
Hold on.
Six, five, and three. Um, wrong.
It should be five, nine, and seven.
Okay, let's try that again.
Okay, good. So, at least I have the right things. Then uh 012 35 79.
Oh, it should be front, not from. All right. Um 25 one two should be five to seven and should be four to five and four to nine.
Yeah. Okay, that's right. I don't know.
Uh, what happened?
Oh, that's my gosh, man.
I didn't even realize I did that. That was a typo. Okay. Looking at it like, wait a minute. Didn't I do this right?
What did I do?
All right. Um, no more debug.
I'm gonna go for it. See how it See how it works.
We're gonna go for There we go.
Beautiful.
Beautiful. Not the fastest solution, but like reasonable reasonable time to solve it. I probably should have solved it a little bit faster. Let's see. Let's see what the fastest solutions look like.
I'm curious.
I am curious.
Let's see.
Okay. Interesting.
So, they wrote a check. They said, "All right, for each query, we're going to do a check." Okay, fine. That's fair.
Um then the check is the length, min value, max value. Okay, for each of these.
So it does do a linear time search over the numbers.
It's a min value and a max value.
does a check to see if the the does a modulate. So terminate early check then it gets the difference d return true another terminate early check visit.
So it it does loop directly through um and get this norm.
Oh, I see. Oh, interesting. So it create they created so it did do it in linear time. Okay, it's faster. Yeah.
So what they did was um basically create a um a vector booleans that checks whether or not a particular number has been visited yet. Um and they actually used the norm which would be they normalize the values.
So the arithmetic sequences aren't that large. Um which means that the set can be kind of small on the smaller side.
Um it's actually the number of arithmetic values that larger. Okay, that's a clever way to do it. So it's this is kind of like linear time. I would say linear time um to process those numbers. But the basic idea would be um okay so you could normalize using the minimum value.
you could take the difference between um I think the way they did it was that you take the difference between the your current value and the nor and the minimum value and then you divide by the the the differential and that's going to give you a normalized value which basically tells you how many times you added B to get to that point. So every element in that arithmetic sequence is going to have sort of a unique normalized value. Um and pretty much if there's a repeat of any normalized values, then you return false. Or if any of those values are not normal, cannot be normalized. In other words, if you divide by D and you get something that's a remainder, then you also return false. So, an arithmetic sequence is going to have every one of those normalized values represented exactly once.
Uh, that's pretty interesting way of doing it. I like that. I didn't think of that.
Um, that's makes it that's a lot faster.
Excuse me. It's pretty good. It's clever.
I was thinking that like there's maybe some way to do this, but I couldn't I couldn't I didn't think of it um quickly.
But yeah, using a um it's not really a frequency map. It's more of just a it's not exactly a set either. It's if you normalize the values and then use a uh a vector booleans, you can check um that those normalized values don't don't appear more than once and that all the values can be normalized. That's a clever clever approach. I like that. Um, okay. So, let me let me take a break.
Um, it's been almost 6 hours here. Also, let me see.
Clever approach. I like that. Um, okay.
So, um, it's been almost six hours here.
Yeah, I'm just looking to see if the stream probably the stream's not getting enough data buffering. Um, it's buffering now. All right, let me wait for it to stop buffering before I stop. Uh, that's an interesting question. I mean, that's all right, I suppose.
So, yeah. Thank you all for watching.
Um, I'm going to get going. I think I'm not going to leave. I think I'm just going to take a break for a little bit and then go do some other things. Uh, okay. The stream is come back now. It's all right. It's good.
It's a bit of a a grind so far. Um, yeah. All right, let me stop here. I'm gonna stop here and then I think I'll go ahead and uh take a break for a few hours, maybe an hour or two, and then come back and do a few more hours. I'll try to do like I was thinking I want to do like eight hours today, but that would be cool. So, yeah. Thank you again for watching, hanging out, saying hello. I appreciate it. Um, let me uh I think yeah, I think I'll just stop here. Just stop. If you like the stream, don't forget to follow uh like the video, all that stuff. and uh or to subscribe.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











