I fucked up

>be me
>live in a ghetto
>be a CS major at the best Mexican University (#113 worldwide)
>spend 3 hours on a bus just to attend lectures
>professor gives some lecture notes
>notes include a pajet tier quicksort implementation (see pic)
>apply to facebook as a joke
>got an interview for a summer internship
>interviewer has a thick Asian accent
>I have a thick Mexican accent
>connection freezes up every 30 seconds
>got asked this question: leetcode.com/problems/intersection-of-two-linked-lists/
>immediately think of a O(n) space O(n) time solution
>i say nothing, wanted to solve it in O(n) space O(1) time
>i can’t
>after 20 minutes the interviewer thinks I’m stupid and gives me the answer
>got rejected
>a girl in my class who barely codes got an offer

I fucked up my only opportunity to get out of this shithole

Attached: quicksort.png (1680x1520, 181K)

Other urls found in this thread:

pastebin.com/WbVSXuMC
leetcode.com/problems/intersection-of-two-linked-lists/
pastebin.com/pTtq5FvH
en.wikipedia.org/wiki/Tony_Hoare
twitter.com/NSFWRedditVideo

You should take hormones and become a tranny. That way Facebook won't have a choice but to hire your ass.

Nigga you always need to prepare for these kinds of interviews months in advance if you unironically want to leave your shithole of a country

t. left my shithole

So the girl was a better coder? Did you think she wasnt because its "her", shitlord?

So you just travel through both lists at about the same time and see if one side ever runs into a visited node on the other?

>any idea how to improve it?
kill yourself

I would recommend installing gentoo

have sex

rate my pajeet tier code
pastebin.com/WbVSXuMC
any idea how to improve it?

>C#
Kill yourself

>O(N^3)
How can you fuck this up so much?

O(n) time O(n) space : Save the longest list in a set, then iterate over the shortest list an check the node is in the set.
O(n) time O(1) space: Make both list the same length and compare both list at the same time.

*and check if the node is in the set

How do I learn to big O?
Read it in a program, and understand what () means.

thumb rule:
O(1) the answer takes the same time no matter how big the input is
O(log n) Google:"binary search"
O(n) 1 for loop from 0 to n
O(n log n) 1 for loop from 0 to n and on each iteration computes a log n operation
O(n^2) 2 nested for loops from 0 to n
O(n^3) 3 nested for loops from 0 to n
O(n!) compute all permutations
O(2^n) compute all combinations

Lots of other companies out there. In these types of interviews you want to say what you're thinking out loud all the time. Don't go silent for a long time or they'll think you don't know what you're doing. Also pick up a how to do coding interviews book or Google that stuff.

TEC? What a faggot lmao

Attached: 1508196592910.png (500x491, 335K)

Beaner here, for interviews you need to show the interviewer your thought process. Start with a complex brute force solution and then optimize as much as you can. Talk about your thoughts while you do it they like that. Don't apply for big companies in Mexico, they know we are cheap as fuck and get away with paying 1/3 of what you are worth (specially Oracle) so go seek some startups there are a lot in Mexico City or GDL, an other option is to freelance for USA, Canada or European companies (work remotely).

The uni you come from and your title mean shit , we are shit country and our universities have shity courses almost on everything IT related, only worth studying medicine here. If you didn't get that memo when you got in then it's your own retardation's fault.

>>got asked this question: leetcode.com/problems/intersection-of-two-linked-lists/
>rating: Easy
>tfw can't figur it out

Attached: 1*g4zsvHxslR-946bI_twV-w.jpg (400x388, 27K)

>>i say nothing
This is where you lost m8. In those interviews, ANY solution gives you much better grades than nothing. Should have explained the o(n)/o(n) solution and immediately followed up with
>this can be done in constant space but I need to think
and only then you can be silent. Likely that the interviewer will tell you to not bother at this point and ask a different question.

Nevermind I was overinking it.

Attached: 1516595731505.jpg (653x490, 95K)

My guess is pre-process both linked lists to find their length, then traverse the longer of the two until they're both the same length, comparing the *next of each node from that point onward.

yes I was dumb and thought ot it's like the tortuise and hare one nd went downt hat path

Here they pay programmers less than a half of what companies pay in other countries for the same amount of experience. I'm discarding getting a programming job here, I'm aiming towards sys admin or some shit

what the fuck is going on in that quicksort

Attached: 1534452318926.png (1118x630, 1.02M)

>i say nothing
never do this in any interview ever, jesus fuck. The only time you shouldn't be talking is when the interviewer is talking.

#include

int partition(int*, int, int);

void quicksort(int *a, int len) {
if(!a || len

I think the do nothing parts were in fact doing two things, both an assertion and a skip ahead (already sorted check).

> Make both list the same length and compare both list at the same time.
I don't think that'll work. If you could go backwards then you could start at the end of both and find a node that was different, but it's a singly linked list

Wouldnt this just be solved by reversing the lists(access the last element if that operation is provided) and iterating backwards until the nodes are different?

You're retarded, you can't solve it in O(1) time. This is a simple iteration problem.

>O(1)
>Iteration

Attached: _090a12a2cffa96e408523f1b99a50e4e.jpg (586x578, 45K)

i minimized the iteration.
what's the O now?
pastebin.com/pTtq5FvH

Attached: 1490300877441.jpg (409x427, 36K)

how do you expect to solve any problem that involves iterating over linked lists in O(1) time? you are an idiot

Yeah but how do you figure out wherever it's O(n log n) or O(n^2) etcetera? OP said, "immediately think of a O(n) space O(n) time solution" but I don't know how to do that.

You are literally replying to the post that answers your question

>wanted to solve it in O(n) space O(1) time
>O(n) space O(1) time

Attached: akko.jpg (188x264, 12K)

Ay virgencita, si la cagaste we

I think it's fairly obvious you are not very good at reading comprehension or causal relationships in presented logic.

That's because the girl has people skills while you are most likely a sperg

people skills > programming skills?

Attached: 1481413110446.jpg (400x400, 27K)

yes if you want a job

>Be me
>Going to school and working full time (work before you get to college so you have interviews and work experience already)
>Already know IT shit, but needed a degree for foot in door
>Know everything being taught, still listen in case I missed something, did all work required
>Studied even more than I needed to
>Class has to do project the whole day, classes are 3 hours. Done in 20 minutes.
>Teacher checked my shit and was impressed, had me help half the side of the classroom while he helped the other
Found out later I got a job offer because of that teacher. Got the job and stayed with them for 8 years. They have 4 people before me that never lasted longer than 3 months.
Advice: Work/study harder than required. It will be the difference between a career or just a job.

This doesn't sort the random numbers correctly, there is something wrong with it.

isnt iteration O(n) ?

Hoare is probably reading this thread and laughing at all of you right now.

Attached: 20190212_163851.png (890x872, 215K)

nice blogpost

The fuck is a hoare?

>Hoare
are you fucking retarded ?
en.wikipedia.org/wiki/Tony_Hoare

>en.wikipedia.org/wiki/Tony_Hoare
tony whore made quicksort

Pinches morros de la unam, se la dan de muy vergas y a la hora de la hora se cagan pa dentro

I think he meant the UNAM

>3 hour bus ride and no hope for the future
He's either at UNAM or IPN
You're supposed to come up with a solution as soon as possible and then tell the interviewer you might find better solution, employers, especially enterprise quality ones, only care about speed
FB isn't so enterprise but for actual quality stuff they employ PhDs and people with plenty of experience
Unless you have divine intellect at programing yeah

>Things that never happened that Jow Forums wishes did

that was a fun question, it made me think for a bit, but did it in O(2n) which is O(n) so mission accomplished.
now post MORE I'm bored

where do I get that comfy google job now?

Attached: screenshot.png (669x372, 32K)

Here's my attempt
>start at end of both lists
>if the last nodes aren't the same, they don't intersect
>if they are the same, go in reverse down the lists, return the node following the first pair that aren't the same
O(n) time, O(1) space (keeping track of the node you might need to return)

Hi econ 100a bro

>Python
>Google
Good going user.

Welcome to normalcy
Though family connections beat people skills here
Basically, you're fucked and can't learn to avoid the fuckery

This is why high IQ people stay NEETs

going backwards in a SLL. ouch.

> He thinks UNAM is a good University for CS

No wonder you fucked up. ESCOM and ITESM are the only decent CS programs in the country