>interviewing for an entry-level programmer position >answer some technical questions to prove I'm not a retard >get to the whiteboard problems >interviewer asks me to write a function to reverse an array >ezpz >push everything onto a Stack, pop back into array >interviewer looks at the solution i wrote on the whiteboard and immediately says "thank you for your time" and shows me out >got rejection email this morning
Did I fuck up?
Joseph Davis
They probably work from a script and are looking for something specific. In the real world you don't spend 20 man hours working on the efficiency of your algorithm when you're working with enough data that it executes in less than a second.
Blake Allen
you're supposed to do it in place that means a simple swap function halfway down the array being reversed
to be fair, I probably would have gottened shitcanned for providing an answer because it would be all pointer arithmetic
Luis Morales
So this: ? public static void reverse(T[] array) { for (int i = 0; i < array.length / 2; i++) { T temp = array[0]; array[0] = array[array.length - i - 1]; array[array.length - i - 1] = temp; } }
Nathan Russell
There's a bunch of different ways to do that. But I'm betting they failed you because if you took some extra time to think about it, this would have been faster and used less space
let's say array size is n you're eating up n units of memory with your solution, and it takes theta(n) time to run.
takes O(n/2), and only uses up 1 unit of memory for the swap
Though it seems kind of harsh to fail you right out the gate on something like that.
Austin Flores
BTW, I'm counting the starting array as free memory.
Carson Watson
>O(n/2) Don't call us. We'll call you.
Gavin Reyes
honestly you might not have ever been in consideration, many places demand a certain number of people get interviewed but really somebody has already chosen their golden boye
Connor Peterson
Oh right, theta(n/2). Fuck, that would've cost me a job.
Jonathan Flores
>interviewer asks me to write a function to reverse an array >push everything onto a Stack, pop back into array wait wat? why you fucked up stack for such dumb shit? why not just i-- from the last element of an array? kek
Colton Anderson
x = [1,2,3,4,5,6,7] x.reverse()
Now what
Bentley Cox
That's not how you use that notation. There is no theta(n/2) or O(n/2)
Nathaniel Flores
there's a bunch of "interview questions" that you're expected to memorize and use cute answers for, this is one of them
get that book with all the software interview questions and memorize them all
Aaron Garcia
Shit, right, 1/2 is a constant. Well, still uses less space.
I could have used for/fold but recursion is prettier.
Jack Reed
this sounds like a racket
Asher Sanchez
Because Stacks are LIFO. They're fucking designed for this.
Nathaniel Peterson
It's pretty dumb, because it's often easier to come up with a less ideal algorithm and then look for ways to improve it. They should have at least prompted OP to see if he could do that.
James Phillips
This... Dont feel bad OP. They have to interview a certain amount of people even though they already know it's going to someone internally already at the company.
Mason Martinez
LOL
Mason Hernandez
>There is no theta(n/2) or O(n/2) Yes there is, namely O(n/2) belongs to the same set as O(n) under the definition of Big O, which is why they are equivalent.
Christopher Edwards
Yeah, I agree. It's rare that I hit upon the perfect solution my first try.
Probably and
Dylan Diaz
This.
Leo Evans
What is it with american interviews?
>Be German >Just finished my masters degree and worked half a year for a dumb side project for a relative >Apply to one company
>Interview boss, one developer, one scrum guy and me >Boss talks one hour about the company >I get to talk a little bit about that tiny bit of previous work experience I have >Scrum guy asks some random questions anyone with a brain could answer >Dev guy asks a single question about a fast way to find out what commit broke the build in a series of commits.
>Get the job.
Henry Diaz
var n = (arr.len() - 1) div 2 for x in 0 .. n: __swap(arr[x], arr[n + x]
Owen Sullivan
Consider OP, that if this is the case, you might have even otherwise been shoein, so the interviewer cut it early to prevent good notes being taken and actual competition for the position occuring.
Luke Williams
>be Swiss >just finished my PhD and have a decent github >apply to 20 companies >not even an interview
Juan Walker
America has a problem with degree mills, professors playing favorites and adjusting marks based on completely non-related factors to education (like if they follow a certain political caste) as well bad references essentially not existing due to fear of being sued.
This means unless someone has transscripts from a known good school, with known good professors (the knowledge of which isn't someone people keep in mind outside HR for big companies either) then you have to actually make the interviewee prove that they can do what they're saying, becuase there is a good chance the actually can't.
Comparatively, in other countries the accrediations mean something, so the interview process is less about making sure you have the knowledge you stated and more about finding if you're a good personal fit/showing you the ropes ready for starting.
Brody Bell
Google employee/interviewer here. The interviewer actually fucked it up. You didn't write the optimal solution because your solution uses O(n) additional memory, but a good interviewer is supposed to essentially coach you into getting the optimal solution without outright giving you the answer. We do this shit all the time.
>write an algorithm to do x >nervous interview candidate who has never written a function on a whiteboard before writes the O(n^2) solution >ask him if he sees any way to improve it >he gets it down to O(nlogn) >ask him if he's heard of y >he has an aha moment, gets it down to O(n) with O(n) memory usage >what if were true? >he writes an O(1) solution with O(n^2) memory usage, obviously unusable in practice but at least he's thinking >recommend that he should be hired
When I was interviewed, I was asked a question to which the naive solution was O(3^n). My first solution was O(n), and with the interviewer's help I got it down to O(logn) and eventually O(1). It was a great experience and I can basically pinpoint it as the moment I was hired.
Jayden James
ez lol int a[] = {1,2,3,4,5,6}; int *it1 = a, *it2 = a+(sizeof a >> 2)-1; while(it1 < it2){ *it1 ^= *it2 ^= *it1 ^= *it2; ++it1, --it2; }
Jaxon Turner
No wonder the best software companies in the world are all American.
Jeremiah Roberts
>Comparatively, in other countries the accrediations mean something, unless it's one of the brown ones where people can scale the side of the building to help students inside cheat
Hunter Miller
same cause of the pointer arithemetic
Bentley Williams
are you retarded?
Jordan Nguyen
Enjoy your pointer decay
Hudson Perez
This code is 100% correct. No decay here.
Jeremiah Turner
>recommend that he should be hired >he fails the SJW / Marxism test two weeks later >get warning for recommending yet another cis white male to be hired >undergo unconscious bias training (again) >they finally release the chips to be implemented into the brains of all google employees so we don't engage in more wrongthink. >I get to keep the part of my brain they cut out for it >Life is good
Samuel Roberts
...
Alexander Jenkins
I didn't mean every country.
Nolan Lopez
this don't worry about it OP, I was interviewed for an IT support position which required fluent english and some german knowledge . I aced the interview but still got rejected because I wasn't the person the company had in mind. They wanted to fill the position with a cute girl who speaks 2 languages and answers the phone. Sometimes if you are not the perfect person you won't get the job the company would rather overwork their current employees in the position than take a person for the job who is not perfect. I don't even know why I traveled to their interview. All of the companies do this shit. If you are even slightly qualified for the position they will call you and interview. They don't give a shit how much you had to prepare and travel to be there. They look at people as objects basically. Just keep trying and sooner or later it will click when the employer is in desperate need of someone or you are the perfect person.
Kayden Young
This is no joke. I referred someone to get a referral bonus. They caught him shitposting Sup Forums from the toilet on his personal cell phone connected to the public wifi. HR started asking me questions. Never going through that again, the measily couple thousand dollars is not worth risking it coming back to you.
Easton Murphy
Slavs are working better than you for half the pay. t.everyone around me works for a swiss company
Wyatt Bennett
Here is a nice way to accomplish what you've been asked
def reverseArray[A](as: Array[A]) = {
val swapping = as.indices zip (as.length - 1 to 0 by -1)
for { (idx, swapIdx)
Sebastian Martinez
This lmao
Alexander Wright
Do Americans really interview with such kindergarten-level retard questions?
Then again the people on Sup Forums are probably not the most qualified candidates...
Caleb Jackson
I think you're right, but that's kinda dumb since it has the same time and space complexity, even if it does waste some space.
Angel Rodriguez
>Dev guy asks a single question about a fast way to find out what commit broke the build in a series of commits. git bisect is pretty great. Everybody refused to use it at my previous job though and would just go through backwards in the commits one by one until it didn't break.
Matthew Sanchez
reverse "TOGGAF A SI PO"
Kevin Barnes
This is some easy shit, OP Your algorithm is good but they were looking for an in-place reverse, not on a stack. Just give them a xor-swap reverse algorithm, they will never complain about that
Alexander Scott
do you know that the wage for tech jobs is about double that of anywhere else in the world and that every top tech company right now is either in america or china
Daniel Evans
What? Did you do it in assembly? Did it take you 10 mins?