Tech interviews

So tell me user, how do you invert a binary tree?

A binary tree is just a data structure in which each node has no more than two childen nodes, mr. examinator. No order is defined on a generic binary tree, so you should clarify what you mean by "inverting".

you clearly misunderstood the question, it asks how do (you) invert a binary tree. Coming up with the spec, dod and tests are part of the exercise. Good luck

1/binary tree

Finding out what the client actually wants is the first step.

>invert
the fuck is that

turn it 360 degrees and walk away

>conducted 6 phones interviews over the last 2 days
>5 could not answer "find all the odd numbers from 0-100"

Sample answers included
>This requires a computer, I cannot do it without a computer
>i = j + 2 = i
>Is it ok if I use three loops?
>I can do this in Java, but not in PHP

Life is suffering.

amerifags cant into proper english

Btw, for this particular example:
>i = j + 2 = i
The conversation continued as follows:

Me: Do you think this code will work?
Candidate: Maybe there is a mistake.
M: What kind of mistake?
C: Maybe syntax error.
M: And if we fix the syntax error, do you think the code will work then?
C: Maybe there is a logic error too.

I laughed. Then I cried.

I'm not even a programmer, but isn't this just a for loop in 100 range with modulo? Basically fizzbuzz but without fizz and buzz.

easy
>turns the monitor upside down

One more:

M: Suppose I want to enter a number into a variable "num", and I want to know if it is odd or even. What will you do?
C: I will run this code:
>cin>>num;
>num/2 = 0;
M: What do you expect to happen, when you run this code?
C: The computer will take your number, divide the number by 2, and check if it is equal to zero. If yes, it is even. If not, it is odd.

I want to find whichever lecturer produced this type of graduate, and inflict physical harm upon them.

>Thank you for the opportunity.

int i = 1
while (i < 100) {
printf(ā€œ%dā€, i);
i = i + 2;
}

how about a loop with half as many steps and without nay division/modulo?

Congratulations, you are better at programming than 5/6 applicants who passed initial screening from about 20 candidates total.

What the hell is going on, I do not know. I want to punch faces.

I'm in STEM taking beginner level courses worried I'm never going to get a job (looking at CCNA then something in networking) and I can already do this after one programming class.

You are making me feel slightly better about my odds of getting a job in IT.

Please post more

i dunno man isnt this ment to be a php webdev job?

>lecturer
Try elementary school teacher.

Read up on how FizzBuzz came be a thing in interviews. When I read it at first, I did not believe it, because the conclusion was that 99.5% of programming applicants did not know how to program at all. Not "pretty bad" or "quite horrid", but had absolutely NO SKILL WHATSOEVER.

It cannot be true, I said to myself. This is an exaggeration. Surely, these people have graduated university, or have had programming jobs. How can 99.5% of programming job applicants have absolutely no skill whatsoever? It cannot be so!

...and here I am, trying, for the third time in three years, to hire one web developer. Just one. And a web dev, not a systems dev or someone to do embedded. Just a web dev. HTML, CSS, and JS, is all I ask.

THREE YEARS, DAMN IT! THREE! I just want ONE web dev! I am now offering a salary that is nearly 50% more than the industry average*... I just want someone who can actually program!

*In Malaysia. We are poorer than Poland.

Depends on where you live but at least here in europe the problem is not finding a job, is getting paid more than change pennies.
STEM degree, pretty much every job offer is 6 months stage with monthly pay ~600 ā‚¬ and you have to pray they don't let you go after those 6 months.

Holy shit. Here I am a recent grad, going over algorithms I haven't touched since junior year worried I won't pass the white board interview.

Are you by chance hiring in Michigan? I know what is a modulus

Malaysia is a county in Ohio, close to you but not close enough unfortunately!

Malaysia.

By law, I am not allowed to hire foreigners, unless I have RM1,000,000.00 paid up capital. That is about USD$250,000.00

We are actually in Kentucky.

If you pay me, i will move to where ever you are. I can program full stack with node, express, apis JavaScript, and any front end template you want. I'll move to Asia in a heart beat. Thats actually my goal.

int from, to;
//std::cin >> from >> to;
int odds = (from != to)?( (to-from)/2 + 1):(0);

Wish I could. The salary I give you will probably be peanuts wherever you are from, but it will be good if you live here.

...but I can't. It is not legal.

What the fuck, man?
Are you sure they are unqualified and not just too nervous to even think? How is it even possible to get a degree in CS and have no idea about such basic programming concepts?
I literally cannot even. Holy shit.
Mad respect for actually tolerating them. I'm certain I wouldn't have the patience.

>hire one web developer
There is your problem. Web developers are brainlets. Especially front-end or "full-stack" ones.

Bummer. How did you end up in Malaysia hiring web devs? That sounds like my ideal situation in a few years. Id love to move to asia, and still have work programming.

>Is it ok if I use three loops?
I wonder what he was going to do.

I just graduated, so I'll let you know how it goes.
First they get their assignment.
Then they wait until the day before it is due to read it over.
Then they have an oh shit moment, and remember they don't know how to code.
Then they go to the computer science tutoring lab, and ask for help.
The tutors who have seen the same problem from every other student, and who are desperate for validation and friends, write the code for them.
Then they hand in the code and graduate without knowing how find the value of the first index of an array.

>not just too nervous to even think?
This is a phone interview, not face to face. And I always let the candidate set the time, so that they can choose whatever is most comfortable. And while some are fresh graduates, most have experience. I put a minimum of 3 years exp as a requirement in the job ad.

I mean, look at pic related.

...and the question is so bloody simple!

>I have to say, we are all very impressed user. You interviewed well and came up with some ingenious solutions to our coding challenges. Before we draw up the contract let's talk a little about your social media presence.

This isn't real. Can't be real.

>user, it seems you actually do not have a Facebook account. Why is that? Facebook is such an important part of our professional lives.

>How did you end up in Malaysia hiring web devs?
Parents brought me here when I was a child. Grew up here, studied here, worked here, got married and had kids here, and now employing people here.

>That sounds like my ideal situation in a few years. Id love to move to asia
You can have an absolutely beautiful life in Asia! Excellent cheap food everywhere, accommodation that costs as much per month as a single pricey meal in US, gorgeous nature as soon as you are about 2 yards outside the city...

...but if you want to hire programmers, it is just as shitty as everywhere else. Maybe even worse. Start a company here if you like (thanks for helping the economy!), but do not depend on being able to recruit good programmers.

var oddNumbers = [];
for (var i in 0...100) {
if (i % 2 != 0) {
oddNumbers.add(i);
}
}
return oddNumbers;

>linear complexity solution

recursively invert each node?

wait you want a constant time solution?

Is this actually a thing anywhere? I haven't had something like this asked even once in the past 10 years.

Well dude you're looking in fucking Malaysia what do you expect
Look in white areas with Ivy league schools if you want people half sane

I speak only javascript sir

ok well here is my constant time solution:

return [/* todo: insert odd numbers here */];

for(i = 0; i < 50; i++) print(2 * i + 1)

int x[] = {1,3,5,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99};

void main() {
for (int i = 0; i < x.length; i++)
System.out.println(x[i]);
}

Heh... Nothin personnel, interviewer...

>tutors writing ""their"" code
As I'm graduating soon(tm) from CS, that made me mad. You're supposed to know all that at that point. What the fuck? It should be illegal.

That grammar made my head hurt. Also
>blatant lies in the cv

Nice bait.

>That grammar made my head hurt.
Compared to what I have seen, this is very good. Very, very good!

Here, have this. It will make your eyes bleed.

var numbers = new List();
var i = 0;
while (i n % 2 == 0);
var odd = numbers.except(even);
return odd.map(n => n).where(true).ToList();

>APPLICATION FOR A VANCACY

This is why you have a fakebook account that's normie friendly. You're creating a persona with your social media accounts, not actually who you are.

WRONG

I'm at a loss of words.
Did you print the letter and put it on display for everyone to see? Everyone should witness this masterpiece of poetry and literature.

In what way? Do you spend most of the time on the job playing Farmville?

>A slow learner is a child of below average intelligence, shoes thinking skills have developed significantly more slowly than the norm for the age. However this development, while being slower.

Man I really want to do this interview stuff one day. Sounds like the most entertaining thing in the world.

I can solve FizzBuzz in visual basic 6
Can I work at google now

let f = mapM_ print
f [1,3..99]

FizzBuzz is just a meme right? Surely anyone with even basic programming knowledge can at least produce a working piece of code for that.

Do a recursive solution?

Invert left sub tree, and invert right sub tree

If sub tree has a child node that has no children (not sure what its called) then swap left and right. Stop when you hit the bottom.

I don't use trees often, so not sure if my terminology is correct....

Interviewing is way more fun than your actual job. When you interview, you get to do fun technical challenges.

Your job will most likely be dealing with shitty APIs, fucked up build systems, and constantly changing requirements. The most challenging thing you'll have to deal with is not going crazy when you argue with people with no stake in the outcome of a new component will debate you over minor irrelevant implementation details.

If you can't handle the mild stress of an interview to the point where you can't answer simple questions, then you are not going to be able to handle the stress of an actual job at all.

A simplified explanation:

Let's say you have nine companies and 18 candidates. 9 candidates are competent, 9 are incompetent. Each of the 9 competent candidates interviews at one of the nine companies, and gets a job. Each of the 9 incompetent candidates interviews at all nine companies, none get jobs. Each company thinks it's hired the top 10% of the industry. Each company also has spent 90% of its time interviewing shitty candidates.

No wait, thats not correct. I think you just need to swap and then call invert on the subtrees till you hit the bottom.

I saw a thread on hackernews where fizzbuzz was unironically described as a "trick question" and a bunch of people agreed.

>If you can't handle the mild stress of an interview to the point where you can't answer simple questions, then you are not going to be able to handle the stress of an actual job at all.

yeah lol NEET life world wide. did a sky-pee interview this morning with a staffing firm called TEK systems, the experience reminded me wut a clusterfuk the merican job market is. they still took the b8 and ask for a few references from kukz i've worked with. smdh it's not like i even want to drive an hour out of town n back twice a day n work in some corp tech support call center.

Interesting perspective.
I just find it hard to believe that people with degrees where programming is basically the foundation allegedly have trouble with such a simple task. I'm not a programmer by any stretch of imagination, and I still found it quite simple.
How the fuck.

Commuting is retarded anyway, most tech workers should be able to work from home 90% of the time, but people are psychotic about offices and shit.

>I just find it hard to believe that people with degrees where programming is basically the foundation allegedly have trouble with such a simple task. I'm not a programmer by any stretch of imagination, and I still found it quite simple.

I don't really get it either. Anyone who can program at all should be able to solve it. I'm sure my mom could solve it if I spent a week teaching her to program. But that's reality.

Who knows? The craziest thread I ever saw on Hacker News was a bunch of users agreeing that you shouldn't be able to block phone numbers without permission or a "good reason" because "anyone should be free to contact anyone."

here
meant to quote

That's the correct approach. They want to see your thought process and if you can work in a professional environment. It's stupid to blindly throw yourself into the solution if the question is ambiguous.

Sounds like a bunch of smart fellas. I'm glad it's easier than ever to block calls.

I just heard about fizzbuzz today in this thread.
Is it literally simply identifying numbers divisible by 3 and 5?

n/2 iterations are still linear you dense fuck. read a fucking wikipedia article before you larp. people like you are the reason g sucks.

invert( BinaryTree);

>carying about complexity in a odd numbers problem to 100

kys please

btw, is P = NP?

from binaryTree import invert
invert(tree)

>here in europe

The hell are you talking about?
Embed systems here, startet 6k.

Yeah, if anything the most important thing for me is to mute all notifications except for a few very close friends and family. Everyone else I will get back to at my own pace.

what country?

germoney?

French/Germany.
First 4months it was only Germany after that we got exchanged to different offices in a somewhat monthly matter.

>French/Germany.
obviously.

that guy was probably talking about eastern Europe or southern Europe.

Admittly Southern is pretty bad right now and I kinda jumped on it, as from my experience everyone smart leaves these places anyway.

Poland isn't that bad these days tho.
You gotta keep in mind that living costs are still dirt cheap there too.

you said France/ Germany.

You said, too, that you would get 6k.

How much of that goes to taxes and how much are the rents/housing costs there?

Turn all the zeros into one's and all one's into zeros

depends on your cultural fit

I'm CTO and I don't know whta a binary tree is.

>Cock Tuning Operator

ok

no, you need to think outside the box and actually architect an enterprise fizzbuzz on the blockchain where you deploy the nodes on aws with kubernates from a cd pipeline

Each node has a Max of two children
Uses some qualifier to make one child "left" and one child "right"
Provides logarithmic time for searching for value
Ex:
You're searching for data with a key value of 11
Top node is 7
11 > 7, so you check the right child
Right child is 15
11 < 15, so you check 15's left child
So on until you reach the value.
Depending on the size of your data, a simple array may be better, but with large amounts of nodes binary trees can be useful.

spbp

for(int i = 1; i < 100; i += 2) {
print("YOU EXPECTED AN ODD NUMBER BUT YOUR MOTHER WILL DIE IN HER SLEEP TONIGHT");
}

I had two interviews over the last couple of days and all they had asked me were my past projects. No algorithms. No data sctructures. And I got one job offer btw. Feels good.

>so user, tell us what do you know about the company and why do you want work here

I wish all the worst to all these mission driven snowflake companies with their manifestos and leadership principles. Playing pretend while they are all the same

binary tree ~= binary search tree

You're right
Although I'm struggling to remember the point of a binary tree that isn't a bst.

>This is a phone interview, not face to face.
Technically, that makes it worse, due to the lack of mimics, body posture and gestics your brain automatically interprets otherwise.

it's like saying what's the point of an array that is not ordered

They're basically giving you an easily answered bonus question. If you can't figure this out then LOL @ you.

Anybody ever asked some Google tier political shit in an interview like how many trannies it takes to invert a binary tree?

Thank god I live in Europe where this shit isn't real.