Job interview questions. Really???? Are these real?



  • Soo.......

    I've got a job interview tomorrow! This is my first job interview for a programmer's position.
    And I've just googled some "Java web dev interview questions".....

    https://www.quora.com/What-are-the-common-interview-questions-in-Java-web-programming
    https://what.thedailywtf.com/topic/2778/a-few-interview-questions

    • How do you know if a linked list has a cycle in it? As in, one of the nodes in the linked list points to a previous node in the list.
    • Describe the characteristics of an ACID database system.
    1. "Write a function that evaluates a polynomial. So, you should be able to feed it the information for the equation, plus a value to evaluate it with, and return the evaluated result".

    2. "Imagine you have a 100K string filled with just the letters A-Z. (for example "ABCBEZBAEBSHJIABHKJIH.....") Write a function that will sort the string so that all of the As are together, all the Bs are together, all the Cs, etc. -- and in order".

    3. "Imagine you have a string composed of just the chars '{([])}" (curly braces, parens, square brackets). Now, assume that you have normal 'mathematical rules', and that sets of parens,braces,brackets have to close in the right order. For instance "()", "()[]", "(({[]}))" are all valid, "(]", "([)]", "{{{{" are not. Write a function that will take an input string and return true if the string is valid, false otherwise"

    Really?

    Let's say it's just a cultural difference but I've never had this kind of questions thrown at me during any interviews back in Korea.

    And I know I'd fail these questions to be honest.

    Reality time. I guess I'm not that good?
    Or are these some kind of special case, like Google or Microsoft?

    I'm not sure if my case was an exception but I never had to use any of the aforementioned type of code to finish any projects.


  • 🚽 Regular

    @Ascendant said in Job interview questions. Really???? Are these real?:

    • How do you know if a linked list has a cycle in it? As in, one of the nodes in the linked list points to a previous node in the list.

    This is a pretty academic question. It's common to have any kind of question revolving around linked lists in any OO language.

    • Describe the characteristics of an ACID database system.

    This is a little odd to me for a Java question. I'd expect this for a DBA or someone who is looking to write their own database implementation. I'd think an employer who is asking about this for a Java position is either looking for someone who has some DBA experience or just gauging how well-rounded the applicant is, in case they needed to reassign or let them help on other projects if needed.

    1. "Write a function that evaluates a polynomial. So, you should be able to feed it the information for the equation, plus a value to evaluate it with, and return the evaluated result".

    A math-oriented question. I'd expect this question from an employer who wants someone who is good with numbers in addition to programming.

    1. "Imagine you have a 100K string filled with just the letters A-Z. (for example "ABCBEZBAEBSHJIABHKJIH.....") Write a function that will sort the string so that all of the As are together, all the Bs are together, all the Cs, etc. -- and in order".

    This is a very common question. I've been asked it on multiple interviews in my career.

    1. "Imagine you have a string composed of just the chars '{([])}" (curly braces, parens, square brackets). Now, assume that you have normal 'mathematical rules', and that sets of parens,braces,brackets have to close in the right order. For instance "()", "()[]", "(({[]}))" are all valid, "(]", "([)]", "{{{{" are not. Write a function that will take an input string and return true if the string is valid, false otherwise"

    This is a good question for gauging one's experience with regular expressions or parsing strings in general. I've never encountered one of these in the wild, but I could see it as a potential question.


    Here's the big thing, though: There's no point in getting hung up over what questions they're going to ask you. In almost all my interviews that involved programming exercises, there were questions I never even fathomed. Every employer looks at the results differently: Either they want a superhero who can ace any challenge they face, they want to gauge how they deal with frustrating exercises (think of a Kobayashi Maru scenario), or they simply want to gauge how advanced they are for placement. I've had all of the above. My current employer gave me two exercises that were reasonably challenging, but not overwhelming, and they expected me to ace it. Another employer in the past ran me through a gauntlet of questions from a wide range of skills and disciplines, and I failed miserably at some of them, but still were impressed with how I handled the difficulty by not throwing my hands up in the air or getting angry, and with the exercises I succeeded at. Another was clearly expecting me to ask questions and wanted to see if I was the type who would spin my wheels trying to figure it out for myself or had the humility to ask for some guidance.

    In the end, it's all a crapshoot. For sure, any decent employer who wants talent is going to be proctoring some kind of a programming exercise. Some do a sanity check fizzbuzz kinda thing, while others really pressure you with stuff they expect you never encountered before. It depends on what kind of skill level they're looking for and what they aim to conclude from the results of the test.


  • Java Dev

    @The_Quiet_One said in Job interview questions. Really???? Are these real?:

    @Ascendant said in Job interview questions. Really???? Are these real?:

    1. "Imagine you have a string composed of just the chars '{([])}" (curly braces, parens, square brackets). Now, assume that you have normal 'mathematical rules', and that sets of parens,braces,brackets have to close in the right order. For instance "()", "()[]", "(({[]}))" are all valid, "(]", "([)]", "{{{{" are not. Write a function that will take an input string and return true if the string is valid, false otherwise"

    This is a good question for gauging one's experience with regular expressions

    Except matching parenthesis is not solvable in regex.



  • @The_Quiet_One ok. So these are normal standard stuff. I actually am more familiar with ACID and the normal forms.

    But in any case, this is going to be a good learning experience.
    I hope I get the job but if I don't because I don't know these then I guess I just have to learn.


  • 🚽 Regular

    @PleegWat Well, there you go. If you start finding Regex patterns, you failed the test. :)



  • These are definitely "mathy" problems, in that they are not the kind of challenges you face when putting together web pages or app screens.

    That said, as far as "mathy" problems go, these are pretty mild. Closer to some normal level of programming, than to the hacker rank kind of stuff I sometimes see, where you have to figure out "the trick" to solve it before heath death of universe.

    If you're having problems with these, you need more practice.



  • @The_Quiet_One said in Job interview questions. Really???? Are these real?:

    This is a little odd to me for a Java question. I'd expect this for a DBA or someone who is looking to write their own database implementation. I'd think an employer who is asking about this for a Java position is either looking for someone who has some DBA experience or just gauging how well-rounded the applicant is, in case they needed to reassign or let them help on other projects if needed.

    Really? You don't think a developer should be able to make an informed decision about what kind of database to use in their app?


  • Discourse touched me in a no-no place

    @PleegWat said in Job interview questions. Really???? Are these real?:

    Except matching parenthesis is not solvable in regex.

    Needs a while loop too. Remove a matched pair (with nothing in between) and loop again until you can't remove anything more. If the string is now empty, the system was all matched correctly. Elementary once you know that you can't really solve it in one fell swoop.

  • Java Dev

    @dkf Well, yes. But I wouldn't go for that unless the question indicated a regex solution was desired.



  • If you are thinking, these question is hard, don't try giving interview in India. :-)


  • Discourse touched me in a no-no place

    @PleegWat You don't need a regex to do it the way I specified. I'd probably use one, as I'm pretty happy with using them (and know their limits well) but the fundamental operation is simple enough to be practical to do with even very simple tools.


  • Java Dev

    @dkf I'd probably walk over it and maintain a stack. Or, if I was allowed to overwrite the input string, use the start of it as the stack.

    EDIT: Just realized this is a java topic - I wouldn't overwrite the input in java.


  • 🚽 Regular

    @cartman82 said in Job interview questions. Really???? Are these real?:

    @The_Quiet_One said in Job interview questions. Really???? Are these real?:

    This is a little odd to me for a Java question. I'd expect this for a DBA or someone who is looking to write their own database implementation. I'd think an employer who is asking about this for a Java position is either looking for someone who has some DBA experience or just gauging how well-rounded the applicant is, in case they needed to reassign or let them help on other projects if needed.

    Really? You don't think a developer should be able to make an informed decision about what kind of database to use in their app?

    Depends on the position. If a developer needs to make such a decision, it means they're at least partially fulfilling the role of DBA. The OP was looking at specific interview questions asked regarding Java. I'm not saying they wouldn't ever ask that as an interview question, but in the specific context of Java it's somewhat of a tangent. Just like asking "What operating systems are you comfortable with?" is a general interview question, but I'd similarly consider it to be an odd example to give of a Java-specific interview question, is all.



  • @The_Quiet_One I still think even a java developer should know something about the database they are using.


  • Banned

    @Nagesh welcome back!


  • 🚽 Regular

    @cartman82 I agree. I'm just saying in the context of "what are some java related interview questions I should expect to get?" It seems like an odd example.



  • @Ascendant said in Job interview questions. Really???? Are these real?:

    I hope I get the job but if I don't because I don't know these then I guess I just have to learn.

    Just remember, "knowing" interview questions that are puzzles is a bad thing if what they want is to see how you go about solving problems. I'd say you ought to do a few puzzles like that to get used to doing them, but they aren't something where memorization is even positive.


  • Banned

    @Ascendant as of these questions. The ones you linked are very standard, run-of-the-mill interview problems. You might (and should) expects many variations on them, but these test a set of universal skills that while not necessarily helpful for actual development, they're extremely common on interviews. At the very least, you should:

    • be able to write a function that does some simple string manipulation;
    • know how linked list works internally and what are the performance and behavioral consequences of that;
    • be able to name a few design patterns off the top of your head (not necessarily know what they mean)
    • spot an error in provided code sample (it's usually off-by-one or incorrectly placed conditional statement or a language-specific gotcha);
    • know lots of useless trivia about your language of choice.

    More senior positions might also require specific knowledge about some libraries and other technologies, but for junior, you can do without. It should be the easiest part.

    As for the three coding task you quoted - they all test your awareness of what the correct approach should be. They're trivial if you do, PITA if you don't.

    Solutions.

    The first one is about iterative multiplication - you take an array of coefficients and the x, multiply each coefficient by x as many times as required, and add it all up.

    The second is about bucket sort - instead of sorting in-place, you make an array of 256 integers - one for each possible char value - and count each character's occurences, then build the result string from that. I was actually asked this exact question on my own interview last Tuesday. I failed.

    The third is about stack - you push opening brackets and pop on closing bracket, checking if popped opener matches the closer. At the end of string, you check if stack is empty.

    And remember: you don't have to ace your entire interview. You just need to show you're good enough for the position you're applying for. And you know you're good. You know you are because I'm telling you that. Positive thinking is the key.

    Hope you find this post at least a bit helpful. And good luck tomorrow!



  • @Ascendant said in Job interview questions. Really???? Are these real?:

    • How do you know if a linked list has a cycle in it? As in, one of the nodes in the linked list points to a previous node in the list.

    This is pretty easy. Just keep a list of all known nodes as you traverse the list and check for the existence of a node against this list for each new node you encounter.

    • Describe the characteristics of an ACID database system.

    Wikipedia's got that covered if you want a detailed answer. Many places will just want to know that you know how to do a SELECT.

    1. "Write a function that evaluates a polynomial. So, you should be able to feed it the information for the equation, plus a value to evaluate it with, and return the evaluated result".

    The requirements on this one are murky, so your first step should be to clarify. Do not feel intimidated, asking for clarification is the mark of a good developer! I might ask, for example:

    "What kind of polynomial? A simple one of the form axn + bxn-1 + ... q = 0? In zeroes form, such as (x - a)(x - b)... = 0? Do I need to handle the case of there being any non-polynomial terms? Am I parsing text for the values, or will they be fed to me from an object? What sort of syntax should I expect for coefficients and exponents?"

    They may also be testing you with intentionally vague requirements to see if you'll challenge them.

    1. "Imagine you have a 100K string filled with just the letters A-Z. (for example "ABCBEZBAEBSHJIABHKJIH.....") Write a function that will sort the string so that all of the As are together, all the Bs are together, all the Cs, etc. -- and in order".

    There are a few ways you could do this. With no constraints on memory usage or execution time, I'd just make a map (or Dictionary if you prefer) where the key is the letter, and the value is a list containing an entry for each occurrence of the letter. Or, you could just store an integer count. Then, you traverse the map/Dictionary inorder and they're all magically in order.

    1. "Imagine you have a string composed of just the chars '{([])}" (curly braces, parens, square brackets). Now, assume that you have normal 'mathematical rules', and that sets of parens,braces,brackets have to close in the right order. For instance "()", "()[]", "(({[]}))" are all valid, "(]", "([)]", "{{{{" are not. Write a function that will take an input string and return true if the string is valid, false otherwise"

    This looks like a stack problem. You'd just have to push each character you encounter and then attempt to pop off when you see an occurrence of a "terminating" character. If the popped value is not what you expect, return false.

    Really?

    Consider yourself lucky. Some companies still demand to know how many golf balls you can fit inside a 747.

    Let's say it's just a cultural difference but I've never had this kind of questions thrown at me during any interviews back in Korea.

    What kind of questions did you get?

    And I know I'd fail these questions to be honest.

    If you're not used to being asked them, perhaps. It's a mating dance sometimes.

    Reality time. I guess I'm not that good?
    Or are these some kind of special case, like Google or Microsoft?

    Keep in mind that there are companies that suck at interviewing, or are stuck using cargo-cultist interviewing techniques that were proven to not be predictive a decade ago. Speaking of "decade ago," I highly suggest reading about some old but effective interviewing methods. It will also give you some insight into the heads of prospective employers as you'll know how better to approach them.


  • Considered Harmful

    @PleegWat said in Job interview questions. Really???? Are these real?:

    @The_Quiet_One said in Job interview questions. Really???? Are these real?:

    @Ascendant said in Job interview questions. Really???? Are these real?:

    1. "Imagine you have a string composed of just the chars '{([])}" (curly braces, parens, square brackets). Now, assume that you have normal 'mathematical rules', and that sets of parens,braces,brackets have to close in the right order. For instance "()", "()[]", "(({[]}))" are all valid, "(]", "([)]", "{{{{" are not. Write a function that will take an input string and return true if the string is valid, false otherwise"

    This is a good question for gauging one's experience with regular expressions

    Except matching parenthesis is not solvable in regex.

    It is in .NET I believe.


  • Considered Harmful

    @Groaner said in Job interview questions. Really???? Are these real?:

    This is pretty easy. Just keep a list of all known nodes as you traverse the list and check for the existence of a node against this list for each new node you encounter.

    Or iterate up to the length of the list and see if there's any more elements.



  • @pie_flavor said in Job interview questions. Really???? Are these real?:

    @Groaner said in Job interview questions. Really???? Are these real?:

    This is pretty easy. Just keep a list of all known nodes as you traverse the list and check for the existence of a node against this list for each new node you encounter.

    Or iterate up to the length of the list and see if there's any more elements.

    You can do that only if the length is stored along with the head pointer/reference and is trustworthy. Traditionally, NULL means the end of the list and we don't need no stinkin' leading length.


  • Considered Harmful

    @Groaner Gotta love that O(n) list.len(). Why wouldn't you store the length?



  • @pie_flavor said in Job interview questions. Really???? Are these real?:

    @Groaner Gotta love that O(n) list.len(). Why wouldn't you store the length?

    Well, it is reliable.

    Back when I was a CS major (circa 2002-3, when they still taught C++ in school), we were given header files for the classes we had to implement and were not allowed to add any new members. So if the teacher didn't give you a length field, you didn't have a length field.

    Not long after I left the university, they switched to Java for the weeder classes and outdid themselves. Because so many students were googling how to implement binary search trees and copy-pasting the code, they added a requirement to the assignment that comparisons against the null value were prohibited. My memory is hazy, but I seem to recall that students had to catch NREs to be in compliance with the rules.


  • Considered Harmful

    @Groaner Your memory is hazy, because NRE is C#. It's NPE in Java.
    Also, what I'd do is just make public static Node NULL = new Node(null);, or just use java.util.Optional.



  • @pie_flavor said in Job interview questions. Really???? Are these real?:

    @Groaner Your memory is hazy, because NRE is C#. It's NPE in Java.

    I must admit that I have had the good fortune of never seeing nor writing a line of Java in my entire career. Point is, it was a great way to teach new programmers bad habits in the name of fighting academic dishonesty.

    Also, what I'd do is just make public static Node NULL = new Node(null);, or just use java.util.Optional.

    That may have worked, depending on the TA's mood.


  • Considered Harmful

    @Groaner Objects.isNull



  • @Groaner said in Job interview questions. Really???? Are these real?:

    Let's say it's just a cultural difference but I've never had this kind of questions thrown at me during any interviews back in Korea.

    What kind of questions did you get?

    You should take this as just an experience of one guy, not the whole nation in general of course.
    I just got questions like what kind of frameworks I've used before, what projects I worked on before.
    I guess that's about it. I never got a problem solving question at any interview and while I worked I never saw the company that I worked for throwing problem solving questions to candidates either.


  • Trolleybus Mechanic

    @Ascendant said in Job interview questions. Really???? Are these real?:

    Let's say it's just a cultural difference but I've never had this kind of questions thrown at me during any interviews back in Korea.

    Yeah, normally the answer to every interview question in Korea is "copy it from StackOverflow".


  • Trolleybus Mechanic

    @Nagesh said in Job interview questions. Really???? Are these real?:

    If you are thinking, these question is hard, don't try giving interview in India. :-)

    Where every QUESTION is "which one of these two stackoverflow answers do you copypasta", which is a trick question because the answer is "both".


  • Trolleybus Mechanic

    @cartman82 said in Job interview questions. Really???? Are these real?:

    I still think even a java developer should know something

    I'm going to stop you there...



  • @Lorne-Kates said in Job interview questions. Really???? Are these real?:

    @Nagesh said in Job interview questions. Really???? Are these real?:

    If you are thinking, these question is hard, don't try giving interview in India. :-)

    Where every QUESTION is "which one of these two stackoverflow answers do you copypasta", which is a trick question because the answer is "both".

    Disgusting. That's just asking to have developers Skeet all over your codebase.



  • @Lorne-Kates said in Job interview questions. Really???? Are these real?:

    @Nagesh said in Job interview questions. Really???? Are these real?:

    If you are thinking, these question is hard, don't try giving interview in India. :-)

    Where every QUESTION is "which one of these two stackoverflow answers do you copypasta", which is a trick question because the answer is "both".

    <sarcasm> very funnee </sarcasm>



  • @Groaner Not nice to make fun of Jon Skeet!



  • @Gąska said in Job interview questions. Really???? Are these real?:

    @Nagesh welcome back!

    Thank You!

    first day at school
    the other children look into me
    for sign of similar fear



  • @pie_flavor said in Job interview questions. Really???? Are these real?:

    @Groaner said in Job interview questions. Really???? Are these real?:

    This is pretty easy. Just keep a list of all known nodes as you traverse the list and check for the existence of a node against this list for each new node you encounter.

    Or iterate up to the length of the list and see if there's any more elements.

    Which is a crappy solution, as it only tells you that there is a cycle, keeping a list of nodes as you go also tells you where the cycle is.


  • Banned

    @Dragoon but executes in O(n) instead of O(n2) or O(nlogn). And often, you only need to know whether there's a cycle, not where exactly. As usual, it all depends on what bigger problem you're trying to solve with finding cycles.



  • @Gąska

    Well, of all the times I have had to find a cycle I have never once not had to than fix it, so perhaps I am biased.


  • Banned

    @Dragoon maybe you're a library writer and the cycle is the library user's problem. And he can simply use the debugger.



  • @Gąska

    I don't doubt that the scenario exists, I was merely stating my experience as always being the poor SOB who had to fix the problem.


  • Considered Harmful

    @Nagesh said in Job interview questions. Really???? Are these real?:

    @Groaner Not nice to make fun of Jon Skeet!

    But whatever happens, do not summon Eric L.
    You'll be irrefutably proven wrong (usually in the form of a blog post) about everything you thought you knew. And you will feel thankful. You will then C#. And it will be good.


  • Banned

    @Dragoon I've just thought up a problem with @pie_flavor's solution. If you have a linked list, just how the hell do you know its size before you traverse it?



  • @Gąska

    It is assumed that the length will be stored with the LL. There are many reasons to keep it around, so it is not a bad idea.


  • Banned

    @Dragoon I can't think of any scenario where having the length stored is beneficial while also the linked list is better choice than regular array-like container.


  • Discourse touched me in a no-no place

    @Gąska said in Job interview questions. Really???? Are these real?:

    I can't think of any scenario where having the length stored is beneficial while also the linked list is better choice than regular array-like container.

    Potentially a queue (where the O(1) insert and remove ops are critical) where you want to know the number of items in the queue sometimes. It's a cheap piece of information to keep. There's a way to fairly cheaply implement a queue using a pair of array-backed lists, but you'd need to measure whether that was better than the simple approach (and if you can limit the queue size, there's ways to make memory allocation faster than standard even with linked lists).


  • Banned

    @dkf said in Job interview questions. Really???? Are these real?:

    @Gąska said in Job interview questions. Really???? Are these real?:

    I can't think of any scenario where having the length stored is beneficial while also the linked list is better choice than regular array-like container.

    Potentially a queue (where the O(1) insert and remove ops are critical) where you want to know the number of items in the queue sometimes.

    Deque.



  • @Nagesh said in Job interview questions. Really???? Are these real?:

    @Groaner Not nice to make fun of Jon Skeet!

    Why not? Based on his activity level, Google practically pays him to sit on SO and rack up those sweet, sweet forumpointzzz. That, in my view, is a poor use of time given that he could instead be here anonymously making dick jokes.



  • @dkf said in Job interview questions. Really???? Are these real?:

    @Gąska said in Job interview questions. Really???? Are these real?:

    I can't think of any scenario where having the length stored is beneficial while also the linked list is better choice than regular array-like container.

    Potentially a queue (where the O(1) insert and remove ops are critical) where you want to know the number of items in the queue sometimes. It's a cheap piece of information to keep. There's a way to fairly cheaply implement a queue using a pair of array-backed lists, but you'd need to measure whether that was better than the simple approach (and if you can limit the queue size, there's ways to make memory allocation faster than standard even with linked lists).

    I like the Game Programmers' Container Selection Guidelines:

    • If it has less than about sixteen elements, use an array or array-like container.
    • Otherwise, use the data structure you would normally use.

  • Discourse touched me in a no-no place

    @Groaner said in Job interview questions. Really???? Are these real?:

    Based on his activity level, Google practically pays him to sit on SO and rack up those sweet, sweet forumpointzzz. That, in my view, is a poor use of time given that he could instead be here anonymously making dick jokes.

    Multitasking.



  • @Gąska said in Job interview questions. Really???? Are these real?:

    I can't think of any scenario where having the length stored is beneficial while also the linked list is better choice than regular array-like container.

    FTFY.

    I haven't used a linked list for literally years (*). I'm not saying there aren't cases where they are useful, I'm also not saying that I haven't met one of those cases in years (I haven't, but that's not quite the point). I am however saying that I haven't seen a case where using something else than a linked list was really making my life and code more complicated or slower.

    So I guess that if I was asked a linked list question in an interview, depending on how it goes I might start by asking the interviewer whether they are interested in skills I might really use on the work, or in CS trivia. If the latter, I might go wild with some overly complicated/obfuscated solution, to see how they react to unexpected stuff. There is no reason they should be the only one evaluating the other side.

    (*) cue multitude of answers pointing out edge cases in specialized software where a linked list is useful, ignoring blissfully the rest of my post ;-)


Log in to reply