I spent a long time trying to think of a descriptive shorter name, but alas I did not succeed. Sometimes that's just how it goes.
@aBigBadWolf
3 жыл бұрын
@@mCoding function name != function description
@neur303
3 жыл бұрын
@Elias Productions Exactly just use a (maybe a little verbose) name instead of a comment. If something too verbose it's also a good indicator for a second look for refactoring. Also a verbose name is inconvenient when used often. In that case again, maybe a candidate for refactoring. Also I noticed that I often wrote comments at the call site where I used it (e.g. because expect weird side effects). Using the name makes that redundant too.
@AndiAbrudan
3 жыл бұрын
Your gig might be python, but I see a bright future in your C++ content. Keep it up
@mCoding
3 жыл бұрын
Thank you very much for your kind words! I will definitely do my best to keep it up.
@jovanxin6762
3 жыл бұрын
Loving this sort of content, more competitive programming/alg/ds lectures would be appreciated!
@zzzeval
3 жыл бұрын
The quality of your videos is superb. I truly don't understand how you don't have more subscribers. Cheers.
@mCoding
3 жыл бұрын
Thanks so much! I know I haven't figured out how to grab a general audience's attention for very long. Working on it and always open to suggestions!
@justingolden21
3 жыл бұрын
I was thinking the same thing like half a year ago. He'll get there. He was at just thousand or so subs before and I was in shock. If he keeps making great vids, getting views, likes, comments, he'll get 100k in no time.
@Al-.-ex
Жыл бұрын
@@justingolden21 you were right!!
@tonysax7464
3 жыл бұрын
Could you work on making the visuals appear alongside the code sometimes? Especially for explaining logic portions like when you explain popTallestUntilRight...()
@karimm.elsayad9539
2 жыл бұрын
Yeah this is where the video lost me. I try to visualize everything, but at some point I couldn't anymore.
@theawakened7739
3 жыл бұрын
YT algorithm boost
@ganelonhb
3 жыл бұрын
Gonna try this when I get home! I haven’t done C++ in a long while. What’s a better ice breaker than a good ol’ algorithm
@niconeuman
3 жыл бұрын
@mCoding, this is a great video as always! You mentioned in a comment that you are looking for ideas for a more general audience. IMHO the more basic or introductory the content the more people interested in it. Of course defining that is complicated. Basic C++ may be harder than intermediate Python, idk. But making intro tutorials of C++ and/or Python (or Julia) maybe a good way to reach a wider audience. I, for example, would love to see a tutorial on some graphical library in C++. How to do in C++ the kind of plots that can be done in Python or MATLAB or Octave, etc. Just an idea.
@mCoding
3 жыл бұрын
Thanks I appreciate the ideas!
@glorytoarstotzka330
3 жыл бұрын
that excited voice at the end was amazing
@VivekYadav-ds8oz
4 ай бұрын
Here's how I did it: Put all the buildings in a priority_queue. Keep track of the tallest building till now. If you encounter a "collision" with the tallest building till now, either you are taller than it, or you are shorter, or equal. If you are taller, congrats! Push yourself into the solution, and now you're the tallest building till now. If you're shorter, well maybe not for long! We "trim" the building (building.startX = tallest_building.endX) and push it back into the priority_queue because it may become a contender of the skyline later on. If you're equal in height, then nothing to push, but you're the tallest building till now. Oh and also in case where you are taller, you need to "trim" the ex-tallest building too as it may also become tallest again later on (ofcourse only trim if it is wider and stretches beyond the newest tallest building's right endpoint).
@VivekYadav-ds8oz
4 ай бұрын
I got 100% in runtime (7ms) and 98% in memory
@eliseuantonio6652
3 жыл бұрын
Although I only know Python, I appreciated your detailed explanations. Great video!
@topperthehorse
3 жыл бұрын
Is putting the return type on its own line something typical? I'm pretty new to C++ and I've not seen that style before. Thanks for the example, I'll give it a try.
@mCoding
3 жыл бұрын
This is "needs to fit on screen even when the font is large" style. Not sure if anyone does this in normal code
@mCoding
3 жыл бұрын
Apparently this is some old school C formatting www.gnu.org/prep/standards/standards.html#Formatting
@megaing1322
3 жыл бұрын
As example, this is the coding style used in CPython. So it is somewhat common at least.
@resilientbit3
3 жыл бұрын
That's from the GNU style guide for Linux application programming, so that you don't have search for function names while looking at someone else's code.
@GalizurHaMalakh
3 жыл бұрын
C89 style function returns. Modern way to return (C++11 and up, if your compiler supports it) is auto FunctionName(param a, param b) -> return_type { // code } (capitalization may vary according to your style)
@john.dough.
3 жыл бұрын
I love your visualization!
@drel9300
2 жыл бұрын
My first reaction when I saw the Building with 3 fields being represented as an std::vector, was also "Seriously why, LeetCode?" Thanks for pointing that out!
@luizchagasjardim
3 жыл бұрын
Using a vector for what is clearly a struct is not only suboptimal, it also makes the code less clear. At first I thought these vectors were the whole list of inputs.
@mCoding
3 жыл бұрын
I had the same misconception when I first saw the problem. I had the biggest visible confusion face in a long time after realizing it was just left right height
@akshaypairaikar3128
3 жыл бұрын
Interesting content, looking forward to seeing more C++ on your channel!
@vinvic1578
3 жыл бұрын
Hi , I'm a bit of a cpp newbie, why does he use noexcept for the getter functions ?
@mCoding
3 жыл бұрын
Hi! This gives a hint to the compiler that I believe an exception will never be thrown during the execution of the function. It allows for additional optimizations by the compiler because that means the compiler doesn't have to add any extra code preparing for stack-unwinding when a potential exception is thrown. If you mark a function noexcept and it does end up throwing an exception though, your program is terminated by calling std::terminate or std::unexpected.
@vinvic1578
3 жыл бұрын
@@mCoding I see ! So I should always use noexcept for very simple functions that I know will never throw an exception, like the getters ? Thanks so much for the response :)
Big fan of the channel, and am a somewhat avid Pythonista, but am interested in learning C++. I'm already fairly proficient in C. Any advice on where to start learning?
@realGeobor
3 жыл бұрын
Why is everything marked as static? I would think that this class is a single instance class so static doesn't seem that useful. Is there some optimization benefit to making the members static?
@mCoding
3 жыл бұрын
The algorithm does not maintain any state so logically it is static. The real answer here though is that it shouldnt even be inside a class, it should just be free functions. But leetcode wants it in a class.
@theawakened7739
3 жыл бұрын
Yoh do multiple comments from one person help with the KZitem algorithm boost ?
@mCoding
3 жыл бұрын
Given what I know about how the neural network from 2016 was built, I'm guessing only one comment per user counts, but it probably doesn't hurt!
@eccentricOrange
3 жыл бұрын
If this was a competition about just number of steps scaling (like how we count big O) rather than time, I guess vectors/arrays won't matter?
@theotherone5754
3 жыл бұрын
Correct.
@vilkillian
3 жыл бұрын
But how you can be sure that buildings are sorted? This whole algorithm collapses if they are not sorted
@mCoding
3 жыл бұрын
The buildings being sorted by left coordinate was one of the assumptions of the problem. If you want to allow unsorted buildings, then just sort them first and proceeed.
@vilkillian
3 жыл бұрын
@@mCoding i've read description and didn't saw this assumption :(
@chasehiatt5595
3 жыл бұрын
I don't know, I think relative performance is much more important to leetcode than the literal number of milliseconds. Because of this, forcing the use of slower data types isn't an issue IMO
@mCoding
3 жыл бұрын
I have to disagree, performance in C++ often (and certainly in this case) comes down to counting heap allocations and cache misses. If you replaced vector with array in everyone's answer you would not find that everyone's answer kept it's relative position.
@LuckyST
2 жыл бұрын
how hard would it be to include "concave" shapes, "flying objects" and/or balcony above the camera?
@see8chsee
3 жыл бұрын
What code editor/IDE are you using in your videos?
@mCoding
3 жыл бұрын
Vscode in this video
@see8chsee
3 жыл бұрын
@@mCoding Thank you. I see you also say PyCharm in another video. I like the theme.
@pseudounknow5559
3 жыл бұрын
Feeding the YT algorithm
@Victor_Marius
3 жыл бұрын
What is the "use" keyword doing?
@Dogberto999
3 жыл бұрын
algo boost comment for good channel & video.
@garryiglesias4074
3 жыл бұрын
Solving skyline ? Easy -> scanline...:)
@zyzzbodybuilding
3 жыл бұрын
Snakes all over the world have a moment of silence.
@robertbrummayer4908
3 жыл бұрын
Excellent
@mCoding
3 жыл бұрын
Thank you! Cheers!
@MithicSpirit
3 жыл бұрын
Discord gang
@mCoding
3 жыл бұрын
Let's get some new members!
@ivanjermakov
3 жыл бұрын
I'm not sure was this done for performance or not, but test code is so copy-pasted. I believe you could use a single function to run all tests, passing an array of tuples "input -> output".
@mCoding
3 жыл бұрын
You're totally right, this was done out of pure laziness, not for performance :)
@castelan3419
3 жыл бұрын
No curves noted in the skyline
@chilly2171
Жыл бұрын
this is so much easier in Python.
@markcuello5
2 жыл бұрын
Help me
@mba4677
3 жыл бұрын
Boooooost
@pinch-of-salt
3 жыл бұрын
C/C++ >>>>>>> Python Any day!
@mCoding
3 жыл бұрын
Gotta go fast!
@osolomons
3 жыл бұрын
Is that like a "extra right shift" operator? :D
@giraculum9981
3 жыл бұрын
@@osolomons It's so unsigned, it ignores signs you've never even heard of.
@Cubinator73
3 жыл бұрын
Except when development time is short and runtime not important.
@spencerbills1125
3 жыл бұрын
Discord gang by the way?
@zxyz2191
3 жыл бұрын
I will never not be impressed by just how consistently ugly C++ is.
@ahmadbodayr7203
Жыл бұрын
Great Vid Bro if you are not muslim Read About Islam❤
@esbensloth
2 жыл бұрын
This code will return an incorrect skyline if buildings are not sorted by left wall positions.
Пікірлер: 82