Live data from Hacker News

I had to give a wrong answer to get the job (2017)

dewitters.com

181–190 of 409 posts

Re: I had to give a wrong answer to get the job (2017)

#181
post #96

Earlier quoted context omitted.

All great until you come across someone with a permanent poker face. During my last interview, the interviewer was frowning the whole time.

As someone with a default poker face I am so sorry, I swear I smile, just on the inside mostly.

It's in the eyes. My resting bitch face is broken up with moments of smizing.

Re: I had to give a wrong answer to get the job (2017)

#182

I bombed an interview at a game company because I gave a right answer that I couldn't get them to understand. I don't remember the exact problem they wanted me to solve, but the answer involved a dynamic collection and they wanted it to grow with constant time complexity. They were probably looking for a linked list. But I said I'd use a dynamic array because those have constant time when averaged over a series of ap…

Interestingly, you can use scheduling to make a non-amortized dynamic array. Your probably know this, but for other commenters who do not— Keep two arrays, of size n and 2n. Initially the first has capacity c = n/2 and the second has capacity 0. Reads go to the first array. When you append, append one element to the first array, and copy two elements to the second array. By the time the first array is full, it has be…

IIUC, this is assuming that memory allocation is O(1)?

Re: I had to give a wrong answer to get the job (2017)

#183

Earlier quoted context omitted.

If I remember correctly, that question likely refers to some argument in the driving manual about speeding. Something along the lines of "speeding in most urban areas doesn't actually help get someone to their destination faster. There are always multiple traffic lights and other cars to contend with, so it's not helpful to go over the speed limit and it increases the risk and severity of an accident." It's perfectly…

it isn't true though. suppose there are n lanes and more than n cars, which is almost always the case in the city. if you pass someone, even just to end up stopped at the same light, you are still ahead of them in line. moving ahead by one slot is a very marginal gain, but it does add up if you pass many cars on your journey. in addition to being ahead by however many slots, eventually you will encounter step-wise ju…

> [...] eventually you will encounter step-wise jumps in travel time where you get through a yellow but the person right behind you has to stop.

Keep in mind that driving manuals are deliberately written at a 6th to 9th grade reading level depending on the state.

Yes, you're right that the gains from speeding are marginal compared to the risk, cost, and stress. But it's hard to communicate that kind of nuance. If the manual just says lead-foots aren't going to get somewhere faster by speeding to each intersection that's "good enough" and very close to reality for the purpose of the manual. National merit semifinalists can get the queue-theory version from their high-school math/driving instructor during driver's ed.

Re: I had to give a wrong answer to get the job (2017)

#184

I bombed an interview at a game company because I gave a right answer that I couldn't get them to understand. I don't remember the exact problem they wanted me to solve, but the answer involved a dynamic collection and they wanted it to grow with constant time complexity. They were probably looking for a linked list. But I said I'd use a dynamic array because those have constant time when averaged over a series of ap…

It sounds like you bombed the interview because your answer was not the correct answer for the domain.

For games, it absolutely does matter that only some appends trigger latency, because that causes stuttering in the game play. A linked list may be slower in most use cases...but the performance cost is fixed and can be easily designed around.

Re: I had to give a wrong answer to get the job (2017)

#185
I have had two engineers in the last few weeks tell me that my (correct) interview answers were wrong. It's extremely frustrating feeling to be already stressed from an interview and then deal with this on top.

In one case I argued for a while until we moved on. In the other, I was able to show the interviewer why I was right and they eventually saw my side. I'm not sure if this was poor communication on my part (definitely possible!) but I felt helpless. Still, I don't think I'd be able to intentionally say an incorrect answer just to get the job.

Re: I had to give a wrong answer to get the job (2017)

#186
post #15

Can't really comment on whether that was the correct way to handle the situation, given that passing the interview was the goal. However, I would have a hard time giving an incorrect answer on purpose. I also consider an interview as an opportunity to learn about the company I'm going to work for, and especially my future colleagues. I would probably try to give a full answer, such as "there's a widely-held concept X…

The goal of the interview shouldn't always be to get the job. If you have any length of career, you are interviewing the company as much (or more) than they are interviewing you. My approach would have been to go with the new idea and see what discussion can come out of it. If they don't have time to get into it, that's one thing but if they are simply not open-minded to new ideas, I don't want to work there.

I don't think I could make a decision about whether I'd want to work for a company on the basis of a single employee's attitude. That person might not even be part of my day to day work group.

Re: I had to give a wrong answer to get the job (2017)

#187

I bombed an interview at a game company because I gave a right answer that I couldn't get them to understand. I don't remember the exact problem they wanted me to solve, but the answer involved a dynamic collection and they wanted it to grow with constant time complexity. They were probably looking for a linked list. But I said I'd use a dynamic array because those have constant time when averaged over a series of ap…

It's not great to have to double your memory usage while you reallocate your array. On more limited devices (see games consoles or mobile devices) you'll end up fragmenting your memory pretty quickly if you do that too often and the next time you try to increase your array you may not have a contiguous enough block to allocate the larger array. There's also the cost of copying objects especially if you don't know if…

> It's not great to have to double your memory usage while you reallocate your array.

You don't have to use a growth factor of 2. Any constant multiple of the current size will give you amortized constant complexity.

> On more limited devices (see games consoles or mobile devices) you'll end up fragmenting your memory pretty quickly if you do that too often and the next time you try to increase your array you may not have a contiguous enough block to allocate the larger array.

If fragmentation is a concern, you can pre-allocate a fixed capacity. Or you can use a small-block allocator that avoids arbitrary fragmentation at some relatively minor cost in wasted space.

> Why copy these objects and incur that cost if you can choose a datastructure that meets their requirements without this behaviour.

We have an intuition that moving stuff around in memory is slow, but copying a big contiguous block of memory is quite faster on most CPUs. The cost of doing that is likely to be lower than the cost of cache misses by using some non-contiguous collection like a linked list.

> as its really not suited to the constraints of games and the systems they run on.

For what it's worth, I was a senior software engineer at EA and shipped games on the DS, NGC, PS2, Xbox, X360, and PC.

Re: I had to give a wrong answer to get the job (2017)

#188
post #149

Earlier quoted context omitted.

Interestingly, you can use scheduling to make a non-amortized dynamic array. Your probably know this, but for other commenters who do not— Keep two arrays, of size n and 2n. Initially the first has capacity c = n/2 and the second has capacity 0. Reads go to the first array. When you append, append one element to the first array, and copy two elements to the second array. By the time the first array is full, it has be…

One thing I’ve always been curious about, can you guarantee worst case linear memory use with this setup while supporting pop() at the same time?

It depends on how strictly the structure of each array is defined, the answer can be yes but I don't know what effect this has on modern superscaler CPUs.

The source array might be considered to have even offsets (0, 2, 4, etc, index left shift 1 bit) relative to the double-sized array.

Addition operations past the halfway value of the smaller array have a relation to values in the second by (Index When a removal operation, like pop(), selects a victim in the source array the corresponding operations must also apply in sync to the values in the larger array.

Re: I had to give a wrong answer to get the job (2017)

#189
post #162

I bombed an interview at a game company because I gave a right answer that I couldn't get them to understand. I don't remember the exact problem they wanted me to solve, but the answer involved a dynamic collection and they wanted it to grow with constant time complexity. They were probably looking for a linked list. But I said I'd use a dynamic array because those have constant time when averaged over a series of ap…

In game dev, that one copy might cause a frame drop. Even if amortized over time the frame rate would be slightly higher, the occasional dip might make it unplayable. Of course, arrays have better cache locality, but they didn't ask about that. They were probably looking for a linked list with a small array in each node, which gives more constant write performance and less cache misses on read.

They didn't ask about latency either. I would have been happy to have the discussion of real-world performance, but we were stuck on the basic "what is the algorithmic complexity of this?" question.

Re: I had to give a wrong answer to get the job (2017)

#190
I was in a job interview several years ago and I was given the following prompt: "You have a database containing locations with their corresponding latitudes and longitudes. We want to be able to input an arbitrary latitude and longitude and have the program return all locations within a radius from that point from the database." My initial reaction was to say "I would use a GIS library/API", but the interviewer wanted me to come up with the algorithm on my own. I had done some GIS work at a previous job, so I started explaining how I'd approach it. I was a bit rusty, but I started explaining what I could remember about the Haversine formula and rhumb lines. The interviewer told me that I was overcomplicating it and explained that I can treat the latitude and longitude as standard Cartesian coordinates. I explained how that wouldn't work as they're spherical coordinates, not planar, and lines of longitude aren't parallel. I believe this is where the problem went from being an issue with technical approach to an issue with expectations. What they really wanted was an algorithm that could find all points a given radius from an arbitrary X,Y coordinate. However, by trying to turn it into a real-world problem with latitudes and longitudes they neglected to consider that they had fundamentally changed the challenge. I'm quite stubborn, and I tried to point out that the question was much more difficult than they intended, but they were equally stubborn and insisted that spherical coordinates could be directly converted to planar coordinates with no issue. Long story short, I didn't get a call back and I'm still frustrated about that interview ~3 years later, but I'm also glad that I stood my ground rather than give an incorrect answer.
Post reply on HN