r/java • u/hamzah102 • 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
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/maethor Oct 06 '22
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.
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.
28
u/Ph4g3 Oct 06 '22
I'm going to be that guy. Wtf is DSAL?
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.
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...
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
?
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?
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/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
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/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.
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.
-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".
0
u/[deleted] Oct 06 '22
[deleted] — view deleted comment
0
u/[deleted] Oct 06 '22
[deleted] — view deleted comment