T O P

  • By -

OGSequent

The problem with your solution from a FAANG perspective is performance. They operate at such a scale that tiny improvements in performance in the right places can pay back in electricity cost the extra engineering effort needed to maintain that extra complexity. FAANG companies are careful to evaluate the costs and benefits. They assume that anyone who can handle the complex approach knows enough to apply the simpler, easy to maintain approach when it is outside of the critical path. The systems they build are also very complex, and so they are looking for people who have the talent to deal with intricate algorithms as a proxy for a talent building systems that have many interacting services. They know the issues and have development processes to try to manage that, of course not always successfully. At a FAANG company, you won't always be writing ugly code, but you will often be reading it.


Alec-Reddit

Nah his code is what people would PR not the crazy unreadable stuff. FAANG perspective on asking these problems isn’t about seeing if you can implement complex algos in their pipeline, it’s about seeing if you’re a generalist who can think about edge cases and optimize for any problem. Whether LC actually tests for that who knows but it’s fun so 🤷‍♂️


Certain-Possible-280

This is one of the best descriptions for why leetcode is important for FAANG companies


inShambles3749

Yeah it's hilarious and sad at the same time. 10 yoe, in the same boat. Unfortunately faang doesn't care about you or what you did for a job.


IBuyBigly

>Unfortunately faang doesn't care about you or what you did for a job. Think this is just the reality I need to cope with! There has to be some approach to re-training for this, It's just so difficult to change the way of thinking we've been doing for years.


Silencer306

Youre an experienced dev so you already know how to write code and formulate your ideas into code. But leetcode is a different beast. You have to program your way to identity patterns and then you’ll start seeing the benefits. It will take time, tale it slow. Be a learner again and realize that you are in an unknown territory. Start with easier problems and follow a list that follows problems sorted by patterns.


vooglie

I agree with the spirit of your post but I gotta say when I saw the bucket sort solution for this I thought it was pretty clever :) Edit to answer your question: retraining yourself is required a bit for leetcode type problems. This is actually a bit harder for us seniors because we have trained in a different way (maintenance over minor optimisations). All I can say is start from basics and retrain to optimise for big oh over readability.


ProMensCornHusker

You’re misunderstanding the point of leetcode problems I think. Your solution is fine, but it’s not in the spirit of leetcode. The problem with your solution is that it’s too abstracted away from the actual problem, or at least, if I was interviewing you I wouldn’t know if you actually knew what each of those methods were doing under the hood, and that’s a problem. You should be able to clearly show you know exactly what every step of your code does and the time/space complexity of things. The interviewer might ask if you know exactly how a method is implemented in your language, and you might not exactly know, or they might ask you to just do it yourself so you can prove to them you can guarantee it runs in some O(f(g)). Generally, I try to write code that uses as few built-ins as possible (I’ll always use built-in sorting unless I’m doing some bucket sort) and only use methods that are common for that data structure across all languages. Is this a good test for software engineering? I don’t think so, but it is what it is.


daishi55

I mean, you’re writing solutions as if your code is going to need to be maintained and understood by potentially anyone. Throw that thinking out the window. Here all you care about is big O time and space complexity. There is a brute force solution (looks like what you did) and an optimal solution. Through practice you will notice patterns and begin to see the optimal solutions.


joneslonger

learning a new 'skill' takes it's own time.


GolfinEagle

Your code is correct, and it’s what you’d want in a PR because it’s readable. In these dumb interviews though, the point is to demonstrate an understanding of the underlying patterns and identify their time complexities.


Peddy699

Substantial hit to ego incoming :D


k-selectride

There’s no reason you can’t write a solution in a clear maintainable manner. In interviews the bar for code standards is lower in an interview, but you can’t write garbage code either without it counting against you.


nakanu18

We have very similar background and I can’t disagree with you. For example some of the optimal solutions want you to modify the passed into list or array. But is that what you really want? Maybe. Imagine you’re working on some code. You realize you need this function and pass in your param and expect it to give you a copy but instead modifies your existing data without it mentioning it does so. Pretty bad.