7 ms·
Role of Algorithms
- raunakchhatwal 3y agoI definitely agree that it improves writing fewer bugs. When I first began using leetcode, I was proud that I was able to begin at leetcode medium and even solve the hard ones because the tip was to grind the easy ones before progressing to medium and hard problems. However, reading up on how DSA interviews are conducted, I realized that I probably would be penalized for not getting my solution right the first few times, whereas my style of solving leetcode problems at first was to get it right only after like the sixth+ try. Also, leetcode problems are also a good way to learn new languages, I'm currently using it to learn Rust, and learning Haskell probably would've been smoother if leetcode supported it.
- quirino 3y agoI immersed myself in Competitive Programming this year and I'm very glad I did. I like it a lot for a couple of reasons: It is a very nice challenge/sport. The skill ceiling is high but there are many high quality resources online. The rating systems on competitive websites makes seeing your improvement very rewarding. It serves as an endless source of problem solving "ingenuity". Many problems have extremely elegant solutions. I find it especially satisfying to find subtle ideas/intuitions from one problem being applicable to another one.
- jhck 3y agoI share that sentiment. I've been practicing Competitive Programming off-and-on for some years now. I still struggle a lot with it. But sometimes I manage to come up with a nice solution, and that makes it all worth it to me. When I make no progress at all, I take comfort in an anecdote I once read about the statistician Jimmie Savage [1]: "Jimmie had what he called 'a long-standing neurosis about Pólya-Szegö' (the most famous and long-lived problem book in analysis). Even when he was working on his first (and major) book in Paris, he was spending evenings on that neurosis. 'Pólya-Szegö humiliates me', he wrote. 'I never really know what's going on, but I can now work quite a few of the problems and seem to learn thereby some things of general interest.'" [2] [1] https://en.wikipedia.org/wiki/Leonard_Jimmie_Savage https://en.wikipedia.org/wiki/Leonard_Jimmie_Savage [2] Quote from Paul Halmos's Automathography
- aiunboxed 3y agoYes as a former competitive programmer I think there are a lot of benefits to learning algorithms - It makes you habitual to pushing bug free code as there is a penalty you give in every wrong submission. - You have to make sure that you get the submission done is shortest possible time, you learn to execute with speed. - You have great debugging skills - Edit (Edge cases as well)
- GuB-42 3y agoI have done a bit of competitive programming, occasionally, but I have never been in a competition where there is a penalty for wrong submission. You obviously have to fix your bugs to validate the answer, and you obviously lose time when you didn't make it right the first time and have to debug your code, but when it comes to ranking, the only thing that mattered is the time it takes to get a right answer. But I agree that competitive programming can be a great exercise. Not just for the algorithm, but also for everything around the algorithm. For instance, you don't have time to waste parsing a list of integers. You have to get these parts right the first time almost without thinking, so that you can focus on the hard parts, like the algorithm. For example, if you are not confident that you parsed the input data correctly, you will lose time trying to figure out if you algorithm was wrong or if you fed it the wrong data.
- aiunboxed 3y agoTop coder, codeforces, they have penalties for wrong submissions right ?
- baobabKoodaa 3y agoCorrect. In fact I'm having trouble thinking up a single counter example of an algorithm competition that doesn't give penalty for failed submissions.
- mynameismon 3y agoThe Informatics Olympiads?
- logdahl 3y agoI have been wanting to get into competitive programming. I am quite an experienced programmer. Is leetcode still applicable, or are there other sites that are more suited?
- matklad 3y agohttps://cses.fi/problemset/ https://cses.fi/problemset/ is by far the best resource I know.
- jhck 3y agoWorth mentioning that there's a companion book to this website: https://cses.fi/book/book.pdf https://cses.fi/book/book.pdf The problems are indeed of very high quality. But it can be a difficult place to start. For example, even the very first problem has an overflow gotcha built into it. Also, Kadane's Algorithm appears as an early problem even though several mathematicians and computer scientists failed to discover it: https://en.wikipedia.org/wiki/Maximum_subarray_problem#History https://en.wikipedia.org/wiki/Maximum_subarray_problem#Histo...
- baobabKoodaa 3y agoThe CSES book and problemset are amazing resources for learning.
- sinkwool 3y agoGreat resource, but it's hard to practice there as a beginner because there are no solutions (unless you solve the problem yourself). So you might have to get comfortable with being stuck. Which is fine when you're experienced, but will demotivate you if you're just starting.
- natrys 3y agoInteresting that they have Assembly, but not C. In practice it seems most people just use C++ (87.5%). Add Python3 (7.5%) and Java (5%) and 99% of submissions are accounted for.
- 3y ago
- theusus 3y agoIMO, Algorithms are overstated. It is just like going to the gym. Will make you healthy, but won't make you an athlete. What I found to be more useful is working abstractions, learning more about language theory, and etc. Algorithm is a branch of Computer Science and should be treated as such. It doesn't surpass or transcend it.
- layer8 3y agoThinking in terms of proofs — what the article mentions as properties and invariants — is what’s critical for writing correct code. This doesn’t necessarily depend on DSA knowledge, but it sure helps in developing the understanding. Likewise, writing code that scales performantly relies on an understanding of asymptotic and amortized runtime, which DSA provides the practical examples of.
- bryancoxwell 3y ago> Do you know why we use i, j, k for loop indices? Because D ijk stra! Wait, really? I love that.
- lioeters 3y agoMy theory is that origially the variable name "i" meant "index", and then when someone needed one or two more temporary variables, they added "j" and "k". Oh, here's a more likely explanation: > i and j have typically been used as subscripts in quite a bit of math for quite some time (e.g., even in papers that predate higher-level languages, you frequently see things like "Xi,j", especially in things like a summation). > When they designed Fortran, they (apparently) decided to allow the same, so all variables starting with "I" through "N" default to integer, and all others to real (floating point). https://softwareengineering.stackexchange.com/questions/86904/why-do-most-of-us-use-i-as-a-loop-counter-variable#answer-86911 https://softwareengineering.stackexchange.com/questions/8690...
- tialaramex 3y agoThere's a recent stream where @tsoding decides to learn Fortran, and soon enough the instructions tell him to turn off Fortran's implicit types with "IMPLICIT NONE". And so of course as a contrary person and with experience of many modern languages with lovely type inference he doesn't want to and... yeah, there's a reason for IMPLICIT NONE. That's not inference @tsoding, it's complete madness.
- School-Cotton 3y agoDoubtful since i is also used as an index variable in mathematics.
- deleted 3y ago[deleted]
- angarg12 3y ago> Somewhat related, I noticed a surprising correlation between programming skills in the small, and programming skills in the large. You can solve a problem in five lines of code, or, if you try hard, in ten lines of code. If you consistently come up with concise solutions in the small, chances are large scale design will be simple as well. Well, my anecdotal evidence doesn't support this. I've done 500+ interviews for big tech, and often it is easy to spot people who have grinded leetcode. They excel at DSA, but fail at system design, or even low level design. The thing is that overall I kind of agree with this article. Leetcode is great as a fun coding exercise. I also think they help the craft like katas help martial artist to practice. The problem is when me getting the job depends on solving a coding puzzle. Sometimes I can solve a leetcode hard with ease and sometimes I get completely blocked in a medium one. Getting a job becomes more of a random toss than assessment of my skills. And yes, my company, and by extension me, are very guilty of this.
- snakey 3y ago> Getting a job becomes more of a random toss than assessment of my skills. I’ve coined a term for this throughout my long job search, it’s called the “leetcode lottery” (patent pending). You can do a couple of hundred leetcode problems, but you’re still at the mercy of the Gods when your technical interview comes around. The worst part of this whole charade is that I come out of most interviews having learned nothing valuable and I can say the same for the interviewer. They haven’t learned about my strengths and weaknesses, etc. I don’t have a better solution for how you can get an idea of my knowledge and skills over 2-3 hours of technical interviews though. And until someone does come up with a better idea, we’re stuck playing this game.
- tayo42 3y agoYou just skip the technical interview completely and start relying on some kind of certification for this
- pjmorris 3y agoI think certification is essentially the same thing as having someone else interview the candidate, so it won't be better and is easier to game than interviews. Working together with someone on the kinds of problems you actually face is the most realistic way to assess a person's abilities on the work to be done because it's less of a proxy than anything else.
- ratmice 3y ago> Debugging complex code is hard, first simplify, then debug I've always made it a point to do a first pass just reading code and forming a hypothesis about the problem (which is often wildly wrong) before making any changes or even running it in a debugger. If nothing else you usually find other oddities, and get more familiar with the code as written. It isn't fast but it tends towards being beneficial for more than just solving the specific bug at hand.
- DrScientist 3y agoAll practice is good, but in my view there is a large difference in quality between having a go yourself and memorising the current state of the art implementation. ie does memorising large tracts of poetry make you a great poet? I think if you do a technical exam - then it should be done in a way that explores how people think - not what they have memorized.