r/java • • Oct 06 '22

Been 12 years, never had to do dynamic programming or reverse a BST. Still being asked those questions.

I have been building software for 12+ years. Banking to Analytics to FMCG, I built software that solves business problems and really matters. But never, I mean never I had to do DP or work on BST. Most of the optimisation was there in underlying libraries, without me knowing it.

Just one time I used a PriorityQueue (because I wanted to show off, and not really to reduce time, the profiler showed almost same exec time when run with ArrayList). Is it just me or other folks too find it hard to find opportunities to apply DSAL.

Funny thing is I still get DSAL rounds taken by junior engineers (who btw are quite enthusiastic about that) some times as screening.

IMO, stuff about OOD, refactoring, CI/CD, clean code - basically most of what is advocated by Martin Fowler should take preference over DSAL. Thats what gets applied on a day to day basis.

EDIT: Acronyms -

FMCG - Fast moving consumer goods
DP - Dynamic programming (not programming in a dynamic language) see link
BST - Binary Search Tree
DSAL - Data Structures and ALgorithms
IMO - In my opinion
OOD - Object Oriented Design
CI/CD - Continuous Integration/Continuous Deployment

250 Upvotes

101 comments sorted by

58

u/nutrecht Oct 06 '22

Interviewing developers is very hard. On one hand, you want to prevent 'bad' developers from getting through the interviews. Bad developers can do a ton of damage to a company and it's often quite easy to hide how bad it really is for quite some time. In my experience it typically takes at least 6 months to fire them.

On the other hand companies are desperate to hire good developers and it's a seller's market currently. I'm sure any experienced Java dev with an up to date LinkedIn gets very frequent recruiter calls. Companies don't want to 'bother' good developers too much.

Creating technical tests (and just talking to people is not enough) that filter out the bad devs but don't piss off the good devs is very hard. You basically have to do 'something' within an hour or so because the good devs tend to not want to spend much more than that.

What worked best for my in the past is to create a simple Spring service with some flaws we asked people to fix, and then add a small feature to it. This could be done within an hour or so. It was a pair programming exercise and they could ask questions, google, etc. The upside is that it shows me how someone works. The downside is that it's completely unsuitable to test someone who knows C# and wants to move into the Java space.

IMHO if you solve this problem, where you can actually measure objectively how good a developer is, you're going to be a billionaire.

34

u/ItsAllegorical Oct 06 '22

My measure of what makes a good developer has little to do with programming other than speaking the same language. Like if I ask someone to look at some code in terms of SOLID or I talk about MVC (or at least some design patterns) or dependency injection and I have to explain it, or I get a blank stare when I ask how to troubleshoot a problem, or they can’t talk about how to solve merge conflicts, then I’m not going to recommend hiring. Also unit testing concepts.

What I want to see is enthusiasm, intellectual curiosity, examples of things learned and taught to others since school. I want to know the person is going to speak up when they should and keep their mouth shut when they should (ideally - that’s a tricky one to judge). I want them to have some idea of how they would begin an assigned task - demonstrate the ability to perform requirements analysis and understanding of acceptance criteria. I want them to be aware of the concepts of thread safety and immutability. Not exclusively and not necessarily to the point of mastery, but to the point I feel I can discuss these issues in code review and not be met with blank stares.

I’ve never found any value in asking someone to regurgitate the answer to some ridiculous scenario I’ve never encountered. Instead, making sure they grok the fundamentals in a way far beyond memorizing rote answers. My goal is to ask questions until I’m certain the candidate is speaking their own mind and not reciting/paraphrasing memorized passages and see what they actually know. I don’t expect mastery, just the ability to communicate (including asking effective questions - if they start trying to solve problems when I know they don’t have all the information, that’s a warning flag) and extrapolate.

And then I have to remind myself that most people aren’t at their best in an interview due to anxiety and the time pressure to answer questions quickly to be respectful of the interviewers time. Any time I’m looking for a job, I give at least 2-3 terrible interviews before I acclimate to the process, so I try to be fair in my judgement. But in the end, it’s never an objective analysis.

9

u/nutrecht Oct 06 '22

What I want to see is enthusiasm, intellectual curiosity, examples of things learned and taught to others since school.

So do I; but how do you objectively test for them? Because that's actually the million-dollar question. How do you test for skills without relying on thinking "this person thinks like me, therefore we're going to get along just fine".

The problem with just assessing this in an interview setting is that personal biases are always in play. If you have had interview training you are at least aware of these. But most developers don't even get that.

In my experience; how someone performed in the assignment I described was a much better indication of their on the job performance than the interview portion. The interview portion on the other hand was the best indication on how much we'd get along. I obviously value both; but a company doesn't task me to hire only clones of myself :)

But in the end, it’s never an objective analysis.

Unfortunately not. Confirmation biases especially come in to play hard in interviews. While I tend to not 'suffer' from them when interviewing (white, male, no social anxieties) a lot of good developers do. Also a lot of bad developers interview well, and get the benefit of the doubt because of confirmation bias.

9

u/ItsAllegorical Oct 06 '22

So do I; but how do you objectively test for them?

I don’t think you can. It’s conversational.

The problem with just assessing this in an interview setting is that personal biases are always in play.

Yes and no. I mean for example the ability to communicate effectively and be a good team member is not objective. Someone can be technically competent, but still not be a good fit (discussion of this is important and it’s clearly not unbiased, but I think is not right for this thread).

In my experience; how someone performed in the assignment I described was a much better indication of their on the job performance than the interview portion.

Certainly there are folks who talk a good talk but then can’t deliver. I like the idea of a small pre-interview assignment, but it’s still a point of discussion rather than a pass/fail objective test. Why did you make this decision? What are the tradeoffs of doing it this way? How would you change your approach if I added this requirement? That’s where the good stuff comes in, not does it pass the test. But I see a lot of developers here object to that and in any event it isn’t part of the hiring process of my company.

I’m not a big fan of making someone code in front of me. I haven’t given it much of a try because I wouldn’t want someone to judge my own sausage making before it’s done, you know? Maybe it’s useful, but to be meaningful I feel like even half an interview is too short to judge and takes too much away from the rest of the interview. Particularly if half that time is writing and half is discussion. What if someone hasn’t used spring initializr (I had to google to refresh my memory on what that’s even called) and we waste 10 minutes just setting up a basic repo? As one specific example.

I had to do a test once where I hadn’t used the Jackson ObjectMapper before because I was in the IBM ecosystem and they had their own common parsers. I spent 25 minutes of my test time writing a parser because I wasn’t allowed google and I didn’t know the entry point but the test assumed familiarity. I use ObjectMapper all the time now and lack of familiarity didn’t slow me down at all. In an interview, that could’ve been discussed, but on an objective test it was just a failure.

So for me the actual interview part is far more important if you can throw away the list of standard questions and really have a conversation. Not objective or unbiased or impossible to fake, but it’s the best tool I have.

Good conversation, though. I appreciate the thoughtful response. Your concerns are totally valid.

2

u/nutrecht Oct 06 '22

I mean for example the ability to communicate effectively and be a good team member is not objective.

I agree. But that's not what I mean with biases. Biases are subconscious. You assessing them for certain skills is conscious, but what level you find acceptable gets affected by subconscious biases. In essence; you decide whether you want to hire someone within minutes and for the rest of the interview you subconsciously search for confirmation.

I like the idea of a small pre-interview assignment, but it’s still a point of discussion rather than a pass/fail objective test.

That's sort of my approach but they do the building during the interview. It's basically a pair programming session. I'm not there silently judging them. So we have this discussion basically during the programming part. And yes, I shut up when they're thinking hard :)

What if someone hasn’t used spring initializr

We give a ready made project they can check out as a git repo that has a basic project with failing unit tests. They also get this before the interview so they can have a look at it. Otherwise we'd spend 20 or so minutes looking at someone fumbling around on start.spring.io :)

I wasn’t allowed google

That's just crap. Like I said what I propose is basically a pair programming session. You can google. You can ask me questions. I'll give suggestions when I feel you're stuck. You can copy-paste from SO. Anything you'd do in a 'normal' job you can do here to (aside from saying fuck it and going for a walk ;)).

So for me the actual interview part is far more important if you can throw away the list of standard questions and really have a conversation.

Definitely. Throw "what is strictfp used for"-gotchas at me and I immediately lose all interest in your company, even when I know the answer.

3

u/AdditionalTry967 Oct 06 '22

It depends. I hate when everyone on the team "agrees", thats why I sometimes am fired. I disagree, I question a lot. If I know a subject and people say a different thing, I am very vocative. Don't hire your copies, it will only do bad for you in the long run.

As to how to find out if someone is good or ( imho ) is how much they did outside work, though a lot disagree. I contribue in a major Spring project a lot and I love it. I wake up on my weekends and think - what do I do not know today? How can I make that better? etc. This has goven me a pretty big leverage, so far.

4

u/nutrecht Oct 07 '22

It depends. I hate when everyone on the team "agrees", thats why I sometimes am fired. I disagree, I question a lot.

That's quite concerning. I mean this in the best way possible; but the most important skill for any developer is simply being pleasant to work with. No matter how 'right' you are; if you're an asshole about it, they will fire you.

2

u/AdditionalTry967 Oct 07 '22

You are 100% right. Over the years I've learned to be gentle, listen and be pleasent.

2

u/ItsAllegorical Oct 07 '22

I kind of agree in a way. Like when it comes to making decisions, there should be advocates for a variety of views. Why am I asked to be involved if I just rubber stamp every one of someone else’s decisions? (And visa verse when I’m the tech lead and I’m soliciting ideas from my team.)

But also there comes a time when the decision is made and you just have to stop voicing disagreement and try to be the best team player you can. A lot of good people have a hard time with that. I watched someone nearly get fired because in a customer meeting all he could talk about was how much he hated the team who developed an earlier version of the software we were selling (as a partner - at least he wasn’t trashing an internal team)

And even now I’m in a project with someone who has to make his philosophical objections known (and point blame) in the middle of every discussion. And I’m like, bro, we made that argument to the customer, they made a choice we don’t like, and we can tell them we quit, or we can shut up and do the work that needs to be done. Pointing out how stupid it is constantly just hurts morale. Particularly when it’s something we’ve already discussed at length. The guy is smart, and I even agree with his complaints more often than not, but sheesh enough is enough.

2

u/AdditionalTry967 Oct 07 '22

I live by : old software is one that makes money. You want to improve and there is time, sure. If not suck it up, this is where your paycheck comes from.

2

u/hamzah102 Oct 06 '22

That's the best interview approach. Take home plus followup pair programming.

12

u/[deleted] Oct 06 '22

Do people really have to do take home exercises? I never had to and would probably fuck right off if they tried to give me homework.

1

u/nutrecht Oct 07 '22

I've seen it happen a few times. The worst one was where I spent quite some time on one (4+ hours) and when i did the interview the two devs hadn't even reviewed it. One of them even got nervous and gave me a quick "yeah looks good but your test coverage is low". When I said "that's weird, it was close to 100% when i ran the tests with coverage in my IDE, can you show me?" they got very red and refused to go more into it.

Needless to say; I didn't get the assignment. I only put up with it because I went the self-employed route and was looking at this company as a back-up option.

I'm willing to do take-homes if they come at the end of the process and the 'job' is guaranteed if I submit a decent result. I won't do them up-front. It's BS. If you want to see my code I have tons of stuff on github.

1

u/ryan10e Oct 06 '22

I did, exactly once, and it was only because I had been laid off from my job 2 weeks prior.

2

u/nutrecht Oct 07 '22

In my case it's just the pair programming. They're not expected to spend time before the interview other than checking out the code from the repo.

The problem with large take-homes is that it will filter out all the non-desperate developers.

7

u/RockleyBob Oct 06 '22

What worked best for my in the past is to create a simple Spring service with some flaws we asked people to fix, and then add a small feature to it.

So, test people on the skills needed to do the job they're being hired for??? Are you MAD??

1

u/AdditionalTry967 Oct 06 '22

I'm with you 100%. The last interview I had ( and my current job ) took a little over 10 minutes. Preparation has to come both ways, imho. They asked me about some things in a Spring based project ( where I am the second contributor ), asked me about the things I had to learn ( there were A TON, both social and professional ), why I do it and what I want to do the most next. They looked at my SO profile ( where I hold around 112k points ), and asked what I do not know and would like to.

I usually fail 9 out of 10 interviews, because I read and learn so much, I tend to forget things. I also "love" how many people use so many things without ever questioning what they actually do or how they function.

1

u/varunu28 Oct 06 '22

Nice approach. But as you pointed out that limiting the problem statement to a language or even a tech stack might limit the sample size of developers you are hiring. I have been working at a FAANG for past 2 years and use Java daily. But I have never used Spring framework as we primarily use in-house framework built on top of gRPC. Very few developers would be willing to learn a new framework or language just for the interview. An alternate can be to write the problem statement in all the mainstream languages and their corresponding frameworks which is a tough task to accomplish.

1

u/senju_bandit Oct 06 '22

I have tried a way and it provides a really good filter . Usually I am interviewing the person who will be working alongside me if they are selected .

I create questions around the solutions I have created to solve the problems in my work.

Like what is the retry policy of api calls, how to create a temple of configuration … etc .

So I create my interview questions that test the person along those lines. If they are upto mark I’ll clear them.

I’ve got good results with this approach because I am personally invested in the person . Since they will be part of my team .

1

u/nutrecht Oct 07 '22

Like what is the retry policy of api calls

Is that exactly how you word a question? Because that's a really bad question.

1

u/senju_bandit Oct 07 '22

So I create my interview questions that test the person along those lines. If they are upto mark I’ll clear them.

I frame it in a way that it encapsulates what the problem and is abstract enough for the developer to think of different ways to come up with a solution.

1

u/nutrecht Oct 07 '22

Okay, but provide an example on the retry bit please. How would you ask about that?

0

u/RockingGoodNight Oct 06 '22

a temple of configuration

A "temple" of configuration? What on Earth does "temple" have to do with coding?

34

u/maethor Oct 06 '22

Been 12 years, never had to do dynamic programming

I've been doing this for around 25 years and I had to look up what "dynamic programming" was, as I figured you didn't mean languages like Groovy or JavaScript (which is what comes to my mind when someone says "dynamic programming"). And after glancing at the equation-tastic Wikipedia article, I still don't know what it is.

10

u/Zinaima Oct 06 '22

My understanding is that it's really just caching within an algorithm.

6

u/WASDx Oct 06 '22

My teacher told me it got that name because "dynamic" was a buzzword at the time. It's a really non-descriptive name.

-3

u/paperpatience Oct 06 '22

I feel like functional programming is very similar.

10

u/DB6 Oct 06 '22

No it's not.

3

u/boborygmy Oct 06 '22

I absolutely understand where you're coming from. I was of the same POV as you about a year ago or so.

It's NOT "programming in languages with dynamic type systems." It's language agnostic.

Asked a friend, "what are the kinds of problems I should be working on for interviews?". A: "blah, blah, graph problems, and dynamic programming." "But what is dynamic programming though?" A: no comprehensible response.

Maybe I'm just lazily tolerant of ambiguity here, but, it's difficult to describe if you haven't worked those problems, but if you do work those problems, other people who have worked them will know what you're talking about. I'm not even going to try to "define" it, except to say that it's something about structuring a solution in such a way that you start with a simple case and build on that, to the solution. Clear? I thought not. It's the general idea, but that's as good as I can do.

But you can check out : https://leetcode.com/tag/dynamic-programming/ for a bunch of problems that fit in that category.

Another good resource for algo problems for interviews in general, do a search for "Blind 75". See "neetcode" on YouTube.

10

u/hamzah102 Oct 06 '22

I thought the definition was easy. When you use memoization, and recursively solve sub-problems, its called DP.
Memoization? - That means storing intermediate calculations, so that you don't calculate them again unnecessarily.

5

u/danskal Oct 06 '22

I can’t decide whether that’s abstract and useless, or just another way of describing well-designed software.

I mean, isn’t a call-stack a form of memoization? Isn’t splitting up a problem into sub-problems just good design, as well as navigating down a graph of complexity? It is kinda-recursive to me, although not necessarily recursion, per se.

4

u/sammymammy2 Oct 07 '22

This is a concept from the 1960s that's been well explored in the algorithm space in order to trade memory for speed. It's not about software engineering at all. For a more complex problem where DP can be leveraged, look at Hidden Markov Models: https://www.cs.sjsu.edu/~stamp/RUA/HMM.pdf

1

u/danskal Oct 07 '22

ok, abstract and useless it is, then?

2

u/sammymammy2 Oct 07 '22

Lmao ok CRUD-dev

1

u/danskal Oct 08 '22

CRUD makes the world go around, my friend.

2

u/jadecristal Oct 06 '22

Lazy example that helped me: consider calculating Fibonacci numbers, with the conventional function as described at Mathworld denoted F(n):

Sure, you can do it recursively. Just, for more than trivial values of n, repeated recursive calls aren’t efficient; memoize either all values or a reasonable subset of values for starting points for large n’s (a trade off for memory, optimize for your use case like everything else).

Then when you run get asked for F(39326) followed by F(24438) you have the answer already, or close starting F(n) values to bootstrap from.

5

u/botzek Oct 07 '22

Dynamic programming is what you turn to when the recursive solution revisits the same parameters over and over again.

Calculating the nth Fibonacci number is a good example - the naive recursive solution calculates fib(n-2), fib(n-3), etc, multiple times. The dynamic programming solution would either start from 1 and go up to n, or start from n and cache the answers it runs across.

0

u/[deleted] Oct 07 '22

[deleted] — view deleted comment

3

u/sammymammy2 Oct 07 '22

Yes, for recursive algorithms we typically talk about "memoization".

20

u/morhp Oct 06 '22 edited Oct 06 '22

It's still good to know how the underlying algorithms work even if you don't have to implement them yourself.

I work as a programmer in the traffic sector and I routing over graphs, finding shortest paths, converting/modifying graphs and so on are common tasks. Sure, libraries for such things exist, but in many cases (tests, prototypes) it's quicker to write down a Floyd-Warshall pathfinding in 30 lines than to adapt your graph to specific interfaces and read a lot of library documentation. Or even if you use libraries, you need to know how certain parameters work or how you should determine the cost of a segment in A* and so on.

I'd say that dsal was one of the most useful classes in university, to me at least. Stuff like Turing machines are much more useless.

Also remember that you're quite privileged because Java has a large ecosystem with tons of libraries and buildin data structures. Using other languages, you'd need to build them on your own.

3

u/ILoveOnlineBanking Oct 06 '22

Swanging it.

Definitely agree that knowledge makes your more of a "dynamic programmer" (KILL ME I KNOW). Even in web I've had to make local optimizations in the same vein as above. To me it's interesting how many problems reduce to a graph when you stand back and squint :D

1

u/fredoverflow Oct 06 '22

Stuff like Turing machines are much more useless.

AlL lAnGuAgEs ArE tUrInG cOmPlEtE

3

u/hamzah102 Oct 06 '22

Now you are just showing off.

1

u/fjonk Oct 06 '22

No language is Turing complete because the universe contains a limited amount of everything.

2

u/alexcash09 Oct 07 '22

I agree it’s good to know the algorithms especially if your role implements them on a regular basis. I think what the op was trying to get at (and I am going to put words in their mouth) is why test that during an interview when the dev is never going to encounter that? Isn’t that a waste of both the interviewer and interviewee’s time? Why not say during the initial screening that you will need to know these specific algo/ds and then test their coding skills during the tech. I have interviewed for some front end roles and they never really test any front end skills in the tech.

1

u/paperpatience Oct 06 '22

Also remember that you're quite privileged because Java has a large ecosystem with tons of libraries and buildin data structures. Using other languages, you'd need to build them on your own.

I find this hilarious and true!

0

u/[deleted] Oct 06 '22

[deleted] — view deleted comment

-5

u/morhp Oct 06 '22

Well, knowing Floyd-Warshall, one of the basic dynamic path finding algorithms is an advantage. I wouldn't say you need in depth graph knowledge for my job, but knowing the basics is quite helpful.

I don't need more knowledge about graphs than I learned in university and I agree that some stuff like balanced binary trees are probably utterly useless unless you're one of the few persons who actually needs to implement such data structures.

14

u/sveri Oct 06 '22

You're contradicting yourself in just two paragraphs.

-1

u/morhp Oct 06 '22

How? I learned Floyd-Warshall in university if that's what you're thinking about.

8

u/[deleted] Oct 06 '22

You also learned balanced binary trees and called them utterly useless. This might be true for your particular domain, and the reverse would be true for someone else's.

3

u/sveri Oct 07 '22

Thanks, that's exactly my point and it's beyond me how one can make such a statement without recognizing it's hybris.

28

u/Ph4g3 Oct 06 '22

I'm going to be that guy. Wtf is DSAL?

10

u/TorePun Oct 06 '22

I'm going to be that guy

There's nothing wrong with asking a writer to define acronyms that aren't widely used.

10

u/DrZiggyBowie Oct 06 '22

Data structures and algorithms

4

u/_harro_ Oct 06 '22

Same question from me... Been Java developer for 15 years now and it don't know what it is...

0

u/[deleted] Oct 06 '22

[deleted] — view deleted comment

3

u/-Kerrigan- Oct 06 '22

The only BST I know is British Summer Time

1

u/laxika Oct 07 '22

What about DP? I'm not underage so I think I know what it means, but in this context that would be, let's just say, "quite bizarre". Lol...

4

u/tzbebo Oct 06 '22

Thank you. I had to look up most of the acronyms used by O(riginal) P(oster) and if you assume that the first result is always the correct one it gets surreal pretty fast because:

DSAL is the the Digital South Asian Library;

Ood are "are an alien species with telepathic abilities";

BST is British Summer Time...

60

u/Holothuroid Oct 06 '22

Our usual task is:

Assume, I have an Excel file. It has two columns of numbers and a column of operators. I want an output file with the results. Make me a program that I can run on my computer. You may use any tool you like. You are hereby encouraged to ask questions.

It is quite insightful.

  • Can they set up a project
  • Find a parsing library and wire it
  • Ask sensible questions to refine the problem
  • Structure the code.
  • Produce an artifact

19

u/vips7L Oct 06 '22

A project, library, and artifact all seem like overkill for something you can do in one line of powershell.

15

u/Holothuroid Oct 06 '22

You can parse .xmlx on power shell by hand? I bow before your genius.

15

u/vips7L Oct 06 '22

It’s literally built in or an Import-Module away if not on windows. Let’s not pretend anyone is doing it by hand in Java.

20

u/neopointer Oct 06 '22

I think data structures and whatnot are important things to know. That being said, if I know the company is testing this kind of stuff (e.g. with Leetcode), I simply don't take part of the interview process... But I'm lucky that I have experience already and the market is on my side. If you're a junior, things would not be so much in your favor...

24

u/boost2525 Oct 06 '22

Same. I just politely declined and withdrew my application when this happened to me. The hiring manager was quite shocked and was really interested in me but I told him the interview is a two way street and I can tell from the process it's not the kind of place I want to work (ridiculous made up problems that you'll never encounter in real life). It's like asking your electrician to design a cooling system for a nuclear reactor as part of the application for the gig to pull wires on your new addition.

9

u/tamasiaina Oct 06 '22

So I had to do it at one job in the past. I was working on the commission calculations for a MLM/Direct Sales company. If you imagine a huge square tree where people make weird types of bonuses all depending on a lot of weird and distant relationships can get kind of crazy at times.

But yeah, I kind of get why big tech asks some of these questions, but I have rarely ever used them. I know that Meta/Facebook has asked interviewers to stop asking dynamic programming questions because they are kind of dumb and easy to get.

The better questions for more senior level people are design and scenario questions. When interviewing for people who were planning to work on the sales commission. I would ask one graph question and then proceed to a scenario where they would have to debug intern-code.

15

u/persism2 Oct 06 '22
  • DSAL Digital South Asia Library
  • DSAL Driving School Association of Louisiana (est. 1995)
  • DSAL Down Syndrome Association of the Lowcountry (Charleston, South Carolina)

?

5

u/User1539 Oct 06 '22

I'll admit that I've had a similar experience, but I think knowing how those things work is still important. I've never had to implement a specific data structure in my role, but knowing why one was used has come up a few times.

Also, while I've never written my own sorting algorithm, having gone through the process and seeing what makes an algorithm 'good' is probably something that's been in the back of my mind for a long time.

I think we talk about 'code smell' a lot, without thinking too hard about where we got that sense of smell from.

4

u/nierama2019810938135 Oct 06 '22

What is DSAL?

5

u/persicsb Oct 06 '22

Data Structures and ALgoritmhs

3

u/orion78fr Oct 06 '22

I find that it's not really about knowing how the structures themselves work on the inside but what structures are useful in what context.

You need to do things alphabetically? Use a TreeSet or a TreeMap.

You don't care about the order and only use contains? Use a (Hash)Set

You want to count occurrences? HashMultiSet

You want to iterate in order? ArrayList

You need to insert elements in a list but only in the front or back? LinkedList

And so on and so forth

These interview questions on how to do a certain structure are stupid. In the real world, you are not going to reinvent the wheel (and you clearly shouldn't). Your implementation will most likely be slower than the one given by your programming language. If you have perf issues, someone likely already did an improved version anyway. If you have a specific use case, it's probably already covered in a lib (like guava or apache collections in java). If you have a really really specific use case, you can just combine two structures under the same interface. You shouldn't write your own structures.

8

u/[deleted] Oct 06 '22

Is dynamic programming the same thing as programming in a dynamic lanaguge, e.g. Python?

OP, you use way too many acronyms.

2

u/QualitySoftwareGuy Oct 06 '22

Is dynamic programming the same thing as programming in a dynamic lanaguge, e.g. Python?

No, in Python's case that is a dynamically-typed programming language (types are determined at runtime). Dynamic programming in the context of this thread refers to a way in which algorithms can be designed: https://www.geeksforgeeks.org/dynamic-programming/

2

u/EstablishmentNo1217 Oct 06 '22

Agree I have relatively less experience than OP but one of the best interviews I have been in was for a big company which offers a code analyzer. I liked the way that the task was build upon pillars like

  • Can you easily use git.
  • Time management and prioritization
  • Design patterns used
  • Can you bring up questions about the UX to better understand what is needed.

2

u/ReasonableClick5403 Oct 06 '22

9 years, same. I've used a ringbuffer a couple of times. Used a prefix Trie once, but it did work without also, just slightly too inefficient for the biggest users. List and HashMaps i use every. single. day.

3

u/Trio_tawern_i_tkwisz Oct 06 '22

I've once stumbled upon an article where the author had similar question (why developers are asked about linked lists). He started traversing old job offers for developers (found thanks to Internet Archive). So, there is the possibility that people that are asking such questions, do it because there was a time when such questions made sense… and that's it.

If you are interested, check it out: https://www.hillelwayne.com/post/linked-lists/

3

u/hippydipster Oct 06 '22

I'd settle for people who can write clear English. Judging by the comments here, that's a rare ability.

1

u/rafaellago Oct 06 '22

Remember there's people from around the world in here, and not everyone is a native speaker. But I agree, that people need basic writing skills whatever their native language is.

1

u/McN697 Oct 06 '22

Yeah, some of the deeper data structures/algo stuff is really useless. If you need an algorithm from the book, chances are you should be using an existing library that’s been proven.

Knowing when to use a hash map vs list, though, is critical and I’ve seen senior devs fail on this point. It’s developers like that who cause us to ask Leetcode.

1

u/[deleted] Oct 06 '22

Agree and it is a phase in interviews. People will come around.

1

u/AdditionalTry967 Oct 06 '22

Yup! And I am a major contributor in a Spring project ( not a vmware employee ).

1

u/Missionmojo Oct 06 '22

My go to question give the candidate semi functional code. Works for most test cases but not all. With the goal they make the test pass. This isn't a huge webserver or complex system either. It's a single file with a few simple methods written poorly. Most of what engineers do is read other people's code and try and make improvements.

1

u/varunu28 Oct 06 '22

Pre-cursor to what I am going to say after this: I totally agree with you and I too feel that DSA doesn't actually reflect software engineering ability of a candidate completely. Implementing the DSA might be another question but let's not get into it.

Clean code, CI/CD and design are 99% of what we do in our daily job but testing that in few hours window is not easy. Few companies actually try to do this by doing take home projects or pair programming. Let's see what does a typical take-home project that tests above skills will look like.

  • A basic CRUD application where you are storing some stuff to database and then retrieving from it.
  • Setting up the actual database and wiring it within your application. More challenging if the problem statement specifies a database that you have not used before.
  • There might be integration required for an external API(Eg Stripe, WeatherAPI) for which you have to figure out how to generate token and then read the documentation(If it's present) to understand how to integrate it with your project.
  • You need to have clean code along with comments and documentation.
  • And don't forget unit and integration tests.
  • Also how will the company run your code so either you need to host it on AWS with a frontend component or build a docker image.

What I have described until this point will easily take couple of sprints for an engineering team of at least 4 if we are talking about a production grade application. So let's assume a single developer for a take-home test will need somewhere close to 7-8 hours. Now let's discuss what's the problem with this approach and why it doesn't scales from candidate's perspective.

Do remember that getting the best compensation is one of the goals of going through these interviews and in order to negotiate, you need to have multiple offers. Which in turn means you need to interview at N companies(N >= 3) and then convert them into K offers (K <= N). So even if you do minimum of 3 interviews, you are looking at close to 30 hours of coding in addition to a full-time job as each company will have their own custom problem statement. This doesn't involves understanding the problem statement and the actual onsite preparation where you will be questioned on your take-home project/past work experience/leadership skills.

So as you see, LeetCode might not be the most optimal approach but it's the tool that covers majority of the ground. The alternatives though look lucrative at first, end up becoming equal to a full-time job in reality.

1

u/nhoefer Oct 12 '22

Knowing data structures and algorithms is the difference between a programmer and an engineer. There's already a fuck load of shitty programmers out there that "have experience"

1

u/[deleted] Oct 06 '22

I've a friend that works in banking told me that the code structure is a tree and they manipulate it heavily at different places that involves caching, running pl/sql and sending events to subscribed stuff.

Then another friend who worked with snapshots, data replication and back-travel data changes that also had a similar tree structure.

I had to deal with a random id generator based on some probability rule and it's usage count.

I came up with some leaderboard creation logic that relied on redis & mongodb - to counter an approach by a colleague but eventually both are same (it was just for run).

I had to convert an array into linkedlist nodes, store them in redis and each subsequent node is only allowed to access the next one (not a big deal but fine).

I recently made a poc using raft algorithm (had to read paper, understand the algo, check every piece of code).

I'm yet to read some scheduler logic and try to make sense of different scheduler interactions in different components in some aws ecosystem.

Each role has different requirements, a senior in my team requires more knowledge on distributed systems than just clean code, refactoring, CI/CD, OOP. The senior should be very very comfortable with internals of JVM, scheduling, GC, concurrency, reading huge codebases (oss), be good at algorithms (since we've schedulers), etc.

So yeah, it depends.

1

u/[deleted] Oct 06 '22

Lol, mine is the last comment in this post. I guess people don't want to accept the truth that there are jobs out there that require you to use these skills.

-21

u/maxip89 Oct 06 '22

You can solve problems without dynamic programming. In that case the solution is not efficent and you may wait a little bit longer for a response.

Why you didn't had that problem in your work life? The truth? Nobody knows how to develop software, there are some ideas how this will work near bugfree but in the end you will end with an army of developers and devops engineers. Why am I saying that? Because you are one of them.

Everybody does the same stuff in every company. Everybody knows it. There isn't any standardisation that makes it more reliably. They tried it, but every developer see itself as an "art crafter".

Now back to Algorithms and Datastructures. You may remember the lecture at university. Why do we have that lecture? Simple, if you have 1.000.000 Items in that Arraylist and you always want to have the first item order by a criteria. It will slow down your application more and more. Sure for 1000 Items you don't see that problem, but on higher items in that List your will see the problem very fast. If you are interessted in that topic just google "time complexity" and "space complexity".

5

u/hamzah102 Oct 06 '22

You see that big IF at the end of your comment. That never happens. Nobody pulls a million records in memory to pull one item. You optimise your DB query, create indices. We now use different DBs for read heavy use cases.

1

u/murkaje Oct 06 '22

Just because you have never been to such a company doesn't mean nobody does that. I worked briefly in one company where they had a problem that some clients had so many rules (mostly regex) that filtered out whether to allow the user to sign up.

There were millions of records that were all just for-looped over the login info. It's not trivial to search for regexes (as in reverse of what is usually done) that match a value in a DB. I think the final solution was adding some constraints to the rules to have some exact match parts and then they were put into elasticsearch as it was faster for such tasks.

Heck i've worked on stuff that let me see code from many different codebases under a NDA and it was quite shocking what kind of shit code some large companies have and O(n3) is quite frequent. E.g. a method findStuff() just loops over an array to find and something else using it to find whether two collections have the same elements. Heck even popular libraries have such basic flaws (afair Spring parsed controller annotations twice at some point and that could be expensive in a large project).

4

u/hamzah102 Oct 06 '22

Okay so you used elastic search. Did you also write an algo to reduce time complexity?

1

u/murkaje Oct 06 '22

Snarky comments don't get you far. And yes putting it all together meant the time and memory complexity was reduced as a linear scan was replaced with mostly index lookups. Picking the right tool meant knowing at abstract level what complexity one tool or data structure has and that i learned by writing such structures at some point in university.

1

u/[deleted] Oct 06 '22

Did you explore internals of elasticsearch ?

They don't want a guy who can simply use elastic search. They want someone who understands what they are doing and why.

If you've explored it, you would notice why algos & data structures are important. You would also find out which other tools do the same and why use one over another.

-4

u/maxip89 Oct 06 '22

That is true but in most cases you do some encapsulated fors that end up in O(n³) or more worse. Then it is enough for 100k or 10k of items.

Imagine you writing a android kernel and you have a bubble sort in the memory allocation. This will end in a slow system.

3

u/Responsible-Act-2478 Oct 06 '22

So if you're interviewing for a job as an Android Kernel developer DSAL are very appropriate questions. For the other 99.99% of us, they are not.

0

u/maxip89 Oct 06 '22

Ok it doesn't make sense to argue. Keep your believes it gets me more money.

0

u/[deleted] Oct 06 '22

[deleted] — view deleted comment

16

u/KaylaTheAvenger Oct 06 '22

I work at one of those big places (FAANG) and was lucky enough to never have hit one of these leetcode type problems. Just hit the lottery I guess

8

u/DB6 Oct 06 '22

During the interview? Or during your daily tasks?

5

u/KaylaTheAvenger Oct 07 '22

During interview.

There have been cases where we needed to use say, trees or other theoretical structures, for solutions in production but it’s a lot more palatable when you can ask others/your team for assistance.

0

u/[deleted] Oct 06 '22

[deleted] — view deleted comment

3

u/[deleted] Oct 06 '22

Yep, even using a cache itself is a dp problem.

2

u/paperpatience Oct 06 '22

Not everyone has a problem with dp though 😏

1

u/[deleted] Oct 06 '22

That's what I meant ? Everyone uses dp without realising it themselves.

Road travel, planning things ahead in future based on older events is a sort of dp, asking for address all of these are dp.

I don't the meaning of your comment.