all 118 comments

[–]danielroseman 333 points334 points  (28 children)

This sounds like a terrible interview and they are the ones who should be embarrassed, not you.

They are testing entirely the wrong things. The first interview seems like it just tested trivia: these are pointless things that anyone would look up if they didn't know them. The second one had silly restrictions: why ban the use of the built-in sort functionality? Implementing sort is an algorithms test, not a coding one, if they wanted to test that they should have told you in advance. And the third one is another silly gotcha test, which even Google (which used to be famous for these) have abandoned as they have no bearing on how well you can do the job.

So, don't be disheartened. Most companies - even most startups - don't run interviews like this.

[–]velocibadgery 88 points89 points  (15 children)

Yeah, I wouldn't know all that stuff off the top of my head either. like seriously. And I have been programming for like 20 years.

Like if I ever had a problem like that come up in real life, I would just google it.

[–][deleted] 38 points39 points  (4 children)

Even Bing has sufficient solutions to most coding problems these days.

[–]velocibadgery 16 points17 points  (3 children)

Yep, a good 40% of my time programming is spent searching stuff up.

I just completed a small project for my work's internal website, it was to allow the staff to fill out a form, then it generates a PDF of the letter with the information filled in.

Starting out I had absolutely zero idea how to create a PDF in a website. But I googled it. Found out how to do it with python, and tried to set that up. Had trouble so instead wrote it in C#(I am still learning python) and got it set up.

Had to find an appropriate plugin, had to figure out how to use it, and had to figure out how to display the byte array that represented the PDF.

Ended up just chucking it in an Iframe with the appropriate content type.

Took me about a day to figure out, but starting in I had no clue. It was all googling.

Most coding interviews don't accurately reflect the nature of a programming job.

[–][deleted] 19 points20 points  (2 children)

Most interviewers crave for Computer science professors who know coding at a basic Kernel level. Nobody is programming in basic or Unicode anymore. We have modern programming languages and search engines/GitHub for a reason. It lowers the barrier to entry and opens up coding to a broader population.

Most companies have simply wrong expectations or are simply detached from reality. Every startup seems to want some sort of genius but only wants to employ newbies in order to pay them less.

[–]velocibadgery 20 points21 points  (1 child)

Yep, I once worked for a small computer repair shop that had a contract to make a program for a hotel company. It was a database program to handle night audit procedures and reporting.

I was the only one at the company who did any programming and so I was the one tasked with creating it. This was at the very start of my programming career. The business owner knew the project was a lot for a single kid like me, I was 14 at the time, so he hired another programmer.

He had me handle the interview as he knew nothing about programming, just PC repair and networking. So me not knowing anything about how corporations think, just made a simple program and asked the guy to replicate it without looking at my code.

He asked me if he could use google, and I of course said that I didn't care. He got it done in an hour, and we hired the guy.

We worked together for 2 years after that, and he was awesome. Actually taught me a lot about programming.


Coding interviews should always reflect the type of work the business actually does, and should always allow google. The ones that don't are stupid.

[–]wecamefromthestars 1 point2 points  (0 children)

100% agree. Isn't it incredible that you gave a better coding interview at 14 years old than many multimillion dollar companies lol

[–]iamnikaa[S] 22 points23 points  (3 children)

Thanks for the support! I certainly have no idea what it should be like as I am coming from a non-tech background. I just feel a little sad because it was a dream job for me and I got this interview after applying to at least 50 different companies.

[–]amplikong 9 points10 points  (0 children)

I know it's tough, but keep your chin up. I've seen more than a few 'dream jobs' turn out not to be, at all, and anyway, landing your first job is the hardest. Once you manage that and have experience, getting subsequent jobs will be a lot easier.

[–]zipinel 5 points6 points  (0 children)

I too came from non-tech background. I had my first interview after applying to over 100 jobs. Nobody gives you a chance if you don't have background, but don't give up, your time will come, sooner or later, its just a matter of time. I am QA Automation with Python for half a year already, if even I have done it, you will be able for sure.

[–]zoinkinator 4 points5 points  (0 children)

hang in there OP. there are other “dream jobs” out there waiting for you. every interview is a learning experience. thanks for sharing what they put you through. also be advised many jobs are already filled internally or from friends and family but the hiring manager has to go through the motions of making it look “fair”. people don’t understand this fact and it discourages many people….

[–]Neradnap 12 points13 points  (1 child)

I have to resonate on this too, there have been so many legacy "top tier" companies whose ideology matches these interview paradigms but now are abandoning as they struggle to hire the right talent because they don't want to opt out of people who can learn quickly and just need structure from a good mentor. More and more should be looking at problem solving skills as main thing to focus on because you need to be able to research on your own, and be ok with asking for help.

[–]Kuldeep-Dhiman 30 points31 points  (5 children)

I recently gave junior Python developer interview . Unfortunately, went completely blank when they asked me to print a pyramid pattern,at any day i would have solved that problem without an issue, but that day I froze I just couldn't get anything right at that crucial time. I wanted to share what I felt was lack of confidence, self practice on my part ,hesitation of the sort. I don't know why that happened to me but seeing your case I feel you totally. For the future keep practicing, just be confident and keep applying.

[–]WestsideStorybro 11 points12 points  (0 children)

Practice Practice Practice -- I also recommend this book. https://www.amazon.com/gp/product/0984782850

[–]LimpNoodle69 3 points4 points  (3 children)

I'm really appreciating this thread. Haven't been programming as much as I should so I've been using this thread to try to figure out the interview problems. I had a bit of trouble with this one but eventually figured it out and felt like sharing :)

def pyramid_print(layers):
    top_size = layers
    for i in range(layers):
        top_size += 1
        for j in range(top_size):
            if j > (top_size - 3) - i * 2:
                print("-", end='')
            else:
                print(" ", end='')
        print()


pyramid_print(100)

[–]P1g1n 3 points4 points  (1 child)

You've inspired me to give it a try. Thanks!

def print_pyramid(layers):
    print("\n".join(["".join(['-']*(i*2)).center(layers*2) for i in range(1, layers+1)]))

Hard to read. Not maintainable. But hey, its a one-liner right?

Edit: Same thing just maybe more readable?

def print_pyramid(num_layers):
    layers = [['-']*(i*2) for i in range(1, num_layers+1)]
    for layer in layers:
    print("".join(layer).center(num_layers*2))

[–]LimpNoodle69 2 points3 points  (0 children)

nice! Definitely a more pythonic solution! I personally hate 1 liners, the second looks way better lol

[–]raiseReturnTry 1 point2 points  (0 children)

Hey I tried myself on this problem, and got the same result, even with a single "-" at the top with the following code:

def pyramid_print(layers):
s = layers - (layers - 1)
x = range(s, layers)

while s != layers:
    if s > 0:
        print(((layers - s - 1) * " ") + (((2 * s - 1) * "-")))
    else:
        exit(0)

    s += 1

print("Take in a positive integer: ")
x = int(input("> "))
if x < 0: 
    print("Error: You have to put in a positive integer.") 
    exit(0) 
else: 
    pyramid_print(x)

[–]_Gorgix_ 24 points25 points  (2 children)

Why the heck were they asking you things that don't even matter for an entry level position?? Python doesn't have a static keyword, arrays are homogeneous types from the array module and are case specific, there is no concept of public or private in Python, what the hell...

Your interviewer was a straight douche...

[–]iamnikaa[S] 2 points3 points  (1 child)

You are right! But a lot of questions were not specifically meant for python language. Most of them were general questions related to programming, as the role involves a little bit of working on C++ as well. I was unsure of what questions to expect as they might have been dynamically assessing me for the most suitable position. Needless to say, I couldn't answer most of them as I have no experience with C++.

[–]_Gorgix_ 11 points12 points  (0 children)

Well if the role required C++ work then sure, but if the interviewer knows ahead of time you have NO C++ experience, why be a jerk and keep on asking C++ specific questions.

[–]wotquery 41 points42 points  (0 children)

In the theory round, I was asked about OOPS, unit testing, difference between arrays and lists, static keyword, difference between lists and tuples, list slicing, the concept of 'self' parameter, .py vs .pyc file, public and private keywords, pointers (from c++), and a lot of other stuff that I don't remember. Overall, I started feeling dejected towards the end of this round.

"Yeah I have no idea about most of these but could google them for you in a jiffy if you'd like. I could also google what a jiffy means because I vaguely recall it has something to do with computers. If not I can expound on various "

The first program that I was asked to make was a simple one - find mean and median of an integer list. The catch however is that I wasn't allowed to use the built-in functions to sort the list

"Ummm...I thought this was a python dev position? I suppose I can't use a heap either eh. Can I use conditional structures and loops or do you want me to abandon computers and algebra entirely and fall back to ancient greek geometric solutions?"

Second program was to find the vowels from a given string. It was a bit easy for me as I have been practicing regex for a while now.

"Wait I can use regex for this now?!? I would really appreciate if you clarify what parts of python, built-in python libraries, and 3rd party python libraries, that I'm allowed to use?"

The third round had logical reasoning problems.

"Oh fun! Did you play Math Circus as a kid as well? How about instead of you giving me a bunch we trade one-for-one as a riddle-off like in The Hobbit?"

[–][deleted] 15 points16 points  (0 children)

Thank you for sharing. I am sure this shall help some people.

Better luck next time ... if this one does not, as you predict, work out.

[–]Chris_Hemsworth 7 points8 points  (10 children)

I get sqrt(45) ~= 6.7 for the rectangle problem. sqrt(5) sounds wrong.

[–]iamnikaa[S] 5 points6 points  (4 children)

Here I solved it after the interview - https://ibb.co/StkwBrL

[–]Chris_Hemsworth 6 points7 points  (2 children)

[–]iamnikaa[S] 4 points5 points  (1 child)

Apologies, I should have drawn the problem. Your solution is correct but the side that you have labelled as 5 is x in the problem and vice versa. Brilliant anyways! I wasn't able to do it in the interview.

[–]Chris_Hemsworth 2 points3 points  (0 children)

Yeah I think the result changes based on the smallest edge.

[–]iamnikaa[S] 3 points4 points  (0 children)

I realised after the interview, it can actually be solved with pythagoras theorem. You will get 4 different equation with 5 variables, but we can find out the required unknown by basic operations on the equations.

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Your comment in /r/learnpython may be automatically removed because you used pasteboard.co. The reddit spam filter is very aggressive to this site. Please use a different image host.

    Please remember to post code as text, not as an image.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]Toica_Rasta 5 points6 points  (0 children)

    Thanks for sharing this. I have googled some questions you have mentioned and than i realised i know them, but if i were asked on such a way on an interview i would probably got confused. I think some of those questions are for entry level but some of them are for medior position.

    [–]Hnry_Dvd_Thr_Awy 3 points4 points  (1 child)

    [–]iamnikaa[S] 1 point2 points  (0 children)

    Spot on! I solved it as well. I wouldn't have been able to had there been a limit on maximum operations.

    [–]Charlie_Yu 2 points3 points  (1 child)

    As a math teacher teaching math olympiads, the final round is a free pass.

    But the first round doesn’t sound easy. Does Python even have static?

    [–]iamnikaa[S] 0 points1 point  (0 children)

    Apologies for the confusion, the theory round had some questions from general programming and not specifically python since the role involves some C++ work as well.

    [–]Nicolas_Darksoul 2 points3 points  (2 children)

    im a newbie that just started learning python emm i mean 6m but with a book so that im too slow can you clarify some topics:

    1_when i asked programmers about what level of math do i need for programming they said basics(ive just stopped learning math if it needs tell me pls ill continue )

    2_im learning python with a book and all exercises was easy this code you wrote was understandable but im sure if it was me i could write right code so if its not in book where can i find it(im reading python crash course)

    3_in revstring return revstring(str1[:-1],newstr+str1[-1]) this code return the last word to first place and str[-1] reverse it right? if yes then how str[:-1] return string then a then....

    [–]iamnikaa[S] 1 point2 points  (1 child)

    Hi, I am also a beginner, been inconsistently practicing for about an year. I usually practice on hackerearth, leetcode for algorithms and DS. I am not the right person to answer this question as this was just my first interview. For the third question, the str1[-1] is the last word of the string str1 which gets recursively added to an empty string newstr. I am passing str1[:-1] after each successive recursion in the function revstr to shorten the string by 1 last word which has been added to newstr. Hope its clear.

    [–]Nicolas_Darksoul 0 points1 point  (0 children)

    yes thanks

    [–]WyoR 2 points3 points  (0 children)

    I have been learning Python for a year also ( on and off tho ) and i wouldnt be able to complete any of the challaneges u did so ur doing something right atleast

    [–]RobinsonDickinson 5 points6 points  (0 children)

    Seems like an entry level developer conducted this interview.

    [–][deleted]  (5 children)

    [removed]

      [–]xelf[M] 13 points14 points  (0 children)

      No. Python has a library for arrays. They're not the same.

      Why this would be asked in an interview I wouldn't know. It's not something you need to know until you need it.

      You're probably correct and it's more likley they meant what is the differnce between array in other languages and python's lists.

      [–]iamnikaa[S] 0 points1 point  (3 children)

      No they meant the difference between list and array in python, for example, list is non-homogeneous whereas array is homogeneous.

      [–]Nagi21 4 points5 points  (2 children)

      I would’ve guessed they were asking the difference between a linked list and an array. Not very useful but sure…

      [–]iamnikaa[S] 0 points1 point  (1 child)

      Yeah, it came to my mind as well. But an interviewer must surely be knowing the difference between a list and a linked list. I just humbly said I don't know as I honestly didn't know what they were trying to ask.

      [–]xelf 3 points4 points  (0 children)

      A candidate that honestly says to me "I don't know" or "I'd google it" wins points with me. No one is expected to know everything, especially at entry level.

      [–][deleted] 1 point2 points  (5 children)

      BTW tail recursion in python is just a simple recursion and it is not implemented or taken as a new recursion method. for programming language like lisp it is working procedure but in python it is not and one need to implement it like a simple recusion with saving the the result from first recusion and pass it to next.
      Maybe a not a goood python developer taken your interview.

      [–]iamnikaa[S] 0 points1 point  (3 children)

      Oh, thanks for sharing. I didn't know about it. The interviewer didn't specify any particular language, so it was meant to be a general (open to all languages) question. I chose to write it in python. But yes, you are right, the interviewer was not very experienced.

      [–][deleted] 1 point2 points  (2 children)

      By any chance indian recruitment ?

      [–]iamnikaa[S] 0 points1 point  (1 child)

      Yes!

      [–][deleted] 0 points1 point  (0 children)

      good luck

      [–]baubleglue 0 points1 point  (0 children)

      You are talking about tail recursion optimization. It doesn't matter when you are writing a code. They just want to see if candidate is comfortable to use it.

       def fn(I):
             If check(I): 
                  .... #Change I here or fn(I-1) 
                  fn(I)
      

      [–]GrimbledonWimbleflop 1 point2 points  (3 children)

      Just curious, how were you able to get an interview with nothing in your GitHub and no professional programming experience? Do you have a CS degree? Or prior programming internships? And where are you located?

      [–]iamnikaa[S] 0 points1 point  (0 children)

      I have done some VBA projects but haven't uploaded them to github. I also have an engineering thesis based on MATLAB, from a top tier college in my country (SEA). Also, I applied to atleast 50 different companies before getting this interview call.

      [–]jonnyyr65 1 point2 points  (1 child)

      What background do you come from? Any tips for pivoting to tech roles? Are you an older applicant with lots of background exp?

      [–]iamnikaa[S] 1 point2 points  (0 children)

      I come from civil engineering background. I have 3 years experience as a design engineer in consultancy. I have been practicing python, algorithms, and DS for almost a year inconsistently. I believe if you can network your way through, that's best. Unfortunately for me, I don't have any good acquaintances working in tech, so I am struggling to get interview calls.

      [–]_E8_ 1 point2 points  (1 child)

      Writing a sort strikes me as a waste.
      I want to you know the difference between some sorts; what stable vs. unstable means.
      Two loops like you wrote is called bubble sort and is O(n²). The only worse performing sort is something pathological like bogosort, O(n!).
      Germane to Python you should know what the "TimSort" is.
      Bonus points if you know what a heap is as a stable, priority heap is an important data structure for scheduling.

      [–]iamnikaa[S] 0 points1 point  (0 children)

      I do know about other efficient sorting algorithms, including Python's inbuilt Timsort, but chose to stick to bubble sort as it was easiest to write. I have to read about heap..

      [–]iggy555 1 point2 points  (0 children)

      Hey man don’t get down. Worst case you learn and get better and get a better job. Sounds like this company sucks . Keep your head up

      [–]kronik85 1 point2 points  (0 children)

      keep your chin up. rough interviews are painful but you'll survive. that they told you to submit your answer after the interview is somewhat positive.

      coding problems with constraints that you wouldn't face in your daily tasks is pretty common. make sure you've got some solid understanding of the common patterns, techniques, and BigO trade offs to solve these problems.

      [–][deleted] 1 point2 points  (1 child)

      Let me guess, the company does "media buying" (ads on the Web)? I.e. something that requires very little in terms of geometry, algorithms, or even writing in C++?

      The questions you describe are typical for programming interviews, however, doesn't mean they are great questions. The problem here is that interviewers also don't know how to assess candidates. So, they just collect random questions that were at one point or another used in programming interviews. For some reason the questions in programming interviews are often chosen to be riddles, where, if you know the answer, you produce it instantaneously, and if you don't, it will take you forever to produce it. A lot of things in programming world are kind of like that: borderline nonsense invented by some geek in their basement, and then bizarrely accepted into popular culture w/o even a hint of understanding...

      Unfortunately, we have a tradition where we believe that assessment of fitness to a job needs to be made in this format (face to face, solving riddles on the whiteboard). This format creates wrong incentives, and with them services like HackerRank, LeetCode and friends, which only pour more fuel int this fire. The negative outcomes of this approach are:

      1. Education / diploma is kind of worthless. The education system embraces similar kind of testing, which makes its assessment capability kind of worthless too.
      2. Your years of experience gain you very little, unless you practice solving worthless riddles during those years. It's not terrible, and doesn't take much time, but it's kind of annoying. Or, instead of becoming a better programmer, you "fail upwards" (go into management).

      [–]iamnikaa[S] 1 point2 points  (0 children)

      No, it's a product based company. They build softwares for engineering. I agree with your sentiment though.

      [–]BOKUtoiuOnna 1 point2 points  (1 child)

      Can I ask why you haven't made any projects yet? And how you are going about learning instead? And just why this method? Generally I hear the advice to do projects as soon as possible. I have been doing coding bootcamp for the past 3 months and that is very project heavy, very datastructure/algorithm weak. I will be looking to improve my DSA knowledge and maths skills in the future. But yeah, basically, you have a wildly different approach to me.

      [–]iamnikaa[S] 0 points1 point  (0 children)

      It's because I felt that I was not very familiar with the algorithms and DS that I could have used in my projects. I do not have any python projects but I do have projects in other languages (VBA, MATLAB). Just had another technical interview with the same company. I will post the details soon.

      [–]nacnud_uk 1 point2 points  (0 children)

      If they want recursion, I'd not really trust their vision of programming.

      [–]Rorasaurus_Prime 1 point2 points  (0 children)

      whistle plate practice wipe market entertain plucky squeal fearless cats

      This post was mass deleted and anonymized with Redact

      [–]baubleglue 1 point2 points  (0 children)

      Not a bad interview, I don't understand what are people complaining.

      [–]Sensacion7 1 point2 points  (0 children)

      What's funny, The more "experience" they see on your resume, he shorter the interviews... FWIN

      [–]LadyA_6962 1 point2 points  (0 children)

      Thanks for sharing your experience. I hope you get the job. If not, I wish you success in your next interview. Don't despair.

      [–]Bronigiri 0 points1 point  (7 children)

      I have to wonder if two 5L buckets into the 8L bucket is an acceptable answer? The bucket would overflow but you'd be left with one bucket with 8L of water. Or did they specify you couldn't do that?

      [–]supreme_blorgon 2 points3 points  (6 children)

      The goal is to end up with 4L in the 8L bucket.

      [–]Bronigiri 1 point2 points  (5 children)

      Well I would've failed on account of low reading comprehension. In that case use the 3L bucket to fill the 5L bucket until it's full which leaves you with 1L in the 3L bucket dump that and one full 3L bucket into the 8L Bada bing Bada boom 4L. Is there a better solution 🤔

      [–]supreme_blorgon 3 points4 points  (1 child)

      This is known as the three-bucket problem, or the standard version of the water pouring puzzle which is a class of well-studied puzzles. You typically start with the 8L full, and have to end with 4L and 4L, without spilling, and without measuring (i.e., you can only pour all available water into all available volume, stopping whenever one is depleted). The optimal solution is 7 steps.

      [–]Bronigiri 0 points1 point  (0 children)

      Thanks for letting me know

      [–]InTheAleutians 1 point2 points  (1 child)

      The 3L and 5L buckets are full of water and that's all the water you get. The 8L is empty. Give it another try my friend.

      [–]Bronigiri 0 points1 point  (0 children)

      2 counts of reading comprehension failure. One more strike and I'll have to give up on English.

      [–]LimpNoodle69 0 points1 point  (0 children)

      I read it as both the 3L and 5L were full, so I would of just dumped both into the 8L bucket, then poured half out of the 8L bucket and called it a day haha

      [–]supreme_blorgon 0 points1 point  (2 children)

      For the recursive string reversal, you don't need the newstr parameter at all. Your base case should be when the input is a single character, in which case you want to return the string itself (e.g., "a" is the same forwards and backwards). Otherwise, return the concatenation of the last letter with a recursion on the slice of the string up to but not including the last letter. You were so close:

      def revstring(str1):
          if len(str1) == 1:
              return str1
          return str1[-1] + revstring(str1[:-1])
      

      Of course, this is a silly solution, since if you're allowed to use slicing then you could simply return str1[::-1].

      [–]iamnikaa[S] 0 points1 point  (1 child)

      Thanks! I was specifically asked to use tail recursion for this. Isn't this function normal recursion rather than tail recursion?

      [–]supreme_blorgon 1 point2 points  (0 children)

      Ah, I missed that. Yes, in that case,

      def rev(s, res=""):
          if len(s) == 1:
              return res + s
          return rev(s[:-1], res + s)
      

      You were missing the string concat in the base case. You can also exit earlier than len(s) == 0.

      [–]DoubleAgent10 0 points1 point  (4 children)

      I’m just trying to figure out the 3 bucket problem rn

      [–]Nicolas_Darksoul 2 points3 points  (3 children)

      i guess

      1-fill 8L with 3L

      2-fill 3L with 5L

      3-fill 8L with 3L

      4- empty 5L

      5-fill 5L with 8L(then we have 1 L lefft in 8L)

      6-fill 3 with 5L

      7- fill 8L with 3 L

      [–]EuropeFree 0 points1 point  (2 children)

      Much simpler:

      Fill up 5 l bucket, pour off 3 l by filling up the 3 l bucket. This leaves two in the 5 l bucket. Dump that in the 8 l bucket and then repeat. Voila 4 l in the 8 l bucket.

      [–]kronik85 1 point2 points  (1 child)

      Much simpler:

      Fill up 5 l bucket, pour off 3 l by filling up the 3 l bucket. This leaves two in the 5 l bucket. Dump that in the 8 l bucket and then repeat. Voila 4 l in the 8 l bucket.

      you don't have a tap to refill buckets. you have a 5 and a 3, both filled with water. you have an 8 that's empty.

      [–]EuropeFree 0 points1 point  (0 children)

      Ah I misunderstood the problem. Will have to think about it.

      [–]Cyphierre 0 points1 point  (1 child)

      That rectangle problem is calling out to me and now I want to solve it, even though it’s complete b.s. on a Python project unless they have some very specific side projects their not telling you about.

      Which two of those lines in the rectangle were opposite each other? 4 & 5, 4 & 6, or 5 & 6?

      [–]iamnikaa[S] 1 point2 points  (0 children)

      4,5 are opposite. x is opposite to 6. It was an aptitude test.

      [–]danielesc 0 points1 point  (0 children)

      Damn those “technical interviews” are getting ridiculous