I just had an pre screeing technical 'interview' where they asked me to do the fibonacci sequence in an editor...

I just had an pre screeing technical 'interview' where they asked me to do the fibonacci sequence in an editor. I couldn't do it in the half hour I had to do it even with copy and pasting code from the internet. I'm a senior in Computer Science.


Is suicide a valid option?

Other urls found in this thread:

leetcode.com/problems/two-sum/#/description
en.wikipedia.org/wiki/Assignment_(computer_science)#Parallel_assignment
blog.codinghorror.com/separating-programming-sheep-from-non-programming-goats/
twitter.com/SFWRedditVideos

not really, your problem solving skills will probably result in a catastrophic failure

just go look at some pretty pictures and you'll be k

That's really sad user.
I'm a militaryfag who yells at Cisco devices all day, and I could accomplish that in about 12 minutes with internet access.

What exactly have you done in school?

Smoke a lot of weed and program things I like and don't pay attention to things I don't like. So I have a lot of computer vision and ML projects. I can't even reverse a linked list within a few hours.

Well now I don't feel so bad for you. Hope you didn't go into a ton of debt.

Plant shit seeds, grow shit weeds.

I didn't. I got full scholarships my entire way through so I have no debt. But I have no options at this point I think if I can't even do a fibonacci sequence. I'm actually still working on it and I still can't figure it out.

Isn't this simple recursion?

t. CC fag who got rejected from all but one schools for transfer

Yes it is. Should have taken a maximum of like 5 minutes.

>recursion
Please, no.

Cram Leetcode like every other normie CS major, if you don't want to wallow in pathetic NEEThood like everyone else here on Sup Forums.

have you read the python docs? They have a very elegant fibbonacci sequence solution in like 2 lines. Super neat

I really am trying. I spend probably 10 hours a day (currently neet over summer until school) doing leetcode. The problem is I haven't found the answer to a problem yet without resorting to looking it up. Even after spending 2+ hours on some questions.

LOL if you do it with recursion then you're only marginally less retarded than OP. You gotta use DP, if you know what I mean ;)

f[n] = f[n-1] + f[n-2]
where
f[0] = 0 and f[1] = 1

If by DP you mean the minimized version with no table then yes, otherwise you are just as retarded.

# Fibonacci series:
# the sum of two elements defines the next
a, b = 0, 1
while b < 10:
print b
a, b = b, a+b

How are you attempting problems? There's a video from Google somewhere on Youtube where an employee walks through a whiteboard problem.

Basically, start with the brute force solution, and try thinking of techniques you can use to cut through the search space. If you can't even get the brute force solution, I'd be worried, but most interviewers would rather see you progress through your thinking process, rather than give them an autist staredown for 20 minutes and magic a linear-time solution out of your ass.

damn homie what did you do in school?

Pretty much nothing. I didn't study outside of class, if I went to class, but passed and kept my scholarships because my university is shit.

>If you can't even get the brute force solution, I'd be worried


*worrying intensifies*

If a becomes b, wouldn't be b+a end up being b+b?

>Computer Science
>Science

they let you use an editor, that's really nice

your should work on your solving skills, find similar problems and solve in limited time you give yourself and develop calm confident

no because the right side is actually a tuple in the memory

they let you smoke weed in the military?

>I couldn't do it in the half hour I had to do it even with copy and pasting code from the internet
suicide is a valid option

Most people hiccup on the small complication that the 100th number in the Fibonacci far exceeds the maximum unsigned integer value of even 64-bit computers.

No. Python has all kinds of shit that makes sense to programming brainlets but smells like horseshit to anyone that actually knows what the fuck a computer does.

>find similar problems and solve in limited time you give yourself and develop calm confident

Yeah. I've been doing leetcode and failing. In fact I've spent the last three hours on this question:

leetcode.com/problems/two-sum/#/description

You picked the wrong major.

2 nested for loops to try to pair up everything with everything ?

btw, you can train your solving skills even if you're fucking retarded by looking at solutions for a while and understanding them, thinking how you'd arrive at that, revisiting them the next day, etc

the human brain can be shaped and trained to do certain tasks relatively quickly

Show me your fizz buzz

Bit too late to fix that now considering I graduate soon.

that's not really a small hiccup unless you implement your own digit addition via int/char arrays or something which takes away from the problem's original "objective". Although I guess if you had 30 minutes that'd be more than enough time to do that too

en.wikipedia.org/wiki/Assignment_(computer_science)#Parallel_assignment

I'm pretty sure I couldn't do fizz buzz without an editor, 20 hours of time, and Turing coaching me through it.

I realized I needed to do that. The last 3 hours has been spent trying to actually code it without any syntax or OOB errors.

>can fizzbuzz
>can sum primes under 2 million
>can bubble sort
>understand algorithms instead of blindly copypasting
>can do trivial maths such as fibonacci sequence in a heartbeat
>am better than OP in every way despite never going to school
>have yet to get a call back, much more an interview
It's not fair.

it's not the optimal solution but it's a good first approach

in interviews they'd probably ask you to come up with something better

>The last 3 hours has been spent trying to actually code it without any syntax or OOB errors.

practice coding too

you're a mess, you shouldn't be wasting time on bullshit and should be focusing on iproving your skills all day instead

the power of a good resume and cover letter can work wonders

Just get a new degree. You don't have to pay off student loans while you're in school, and then you get a tag a CS degree onto whatever you want to do.

it's always a hash map bro

create/make up experience and put polished non-trivial code samples online

>can bubble sort
there are much better sorting algos

>there are much better sorting algos
it's a Sup Forums meme

>The last 3 hours has been spent trying to actually code it without any syntax or OOB errors.
Holy shit. How'd you make it so far? What shitty institution are you enrolled at?

Do you have any side projects? The way I'm getting callbacks now is because I have a couple very large projects that use image recognition and ML to play video games.

Bubble sort is so comfy though.

>practice coding too

I mean I spend most of my day practicing coding. I don't have a job so I wake up:

4 hours leet code, might solve one question.

4 hours trying to work on an OS I'm building.

4 hours with python and botting video games (working on Diablo now) with screen reading

and then 4 hours with c# improving a project that a decent number of people use.

I'm not exactly getting any better though.

A shit one. 93% acceptance rate level shit.

>4 hours leet code, might solve one question.
>4 hours trying to work on an OS I'm building.
1/10 made me reply

I'm not bull shitting. It doesn't actually do much but it can launch a shell at this point. I just have..problems with algorithms they frustrate me.

you never know cause if OP didn't go to school he might now know about the importance of time complexity, O notation, etc

Not him but I'll use double penetration

Anyone here have actually decent problem solving skills but always take a bigger roundtrip to solve stuff? I can come up with solutions pretty fast, but it's always some kind of spaghetti solution instead of something elegant.

how can you not be able to write a tiny code that compiles in three fucking hours?

>Using DP
>Not using binary matrix exponentianon method

By being stupid? I don't know. I can't solve them. I can't follow the code or understand it and it becomes increasingly frustrating when it crashes on every single mistype I make or can't figure out why it's going OOB.

This doesn't happen with stuff that I do on my own..I know exactly what it needs to do and how to make it do it or I can figure it out. I can't do it with this stuff though and I don't now why...

elegant solutions are usually more difficult to come up with

>but it's always some kind of spaghetti solution instead of something elegant.
you need to learn to discard your own shit solution and keep working in better ones

it's hard as fuck btw because your brain already got its "reward"

>It doesn't actually do much but it can launch a shell at this point
lol
I'm amazed people still fell for it after that, as if it wasn't obvious enough already

they let you out of high school with that reading comprehension?

There's literally a closed formula that you must've seen in linear algebra class

Just had a job interview,
i had to reverse a string:
Did it recursive, they almost fapt to my code.

Writing javascript for too long addles the brain.

public static int[] Main(int[] nums, int target) {

foreach (int onum in nums) {

foreach (int inum in nums) {

if (onum + inum == target) {
return new int[] {onum, inum};
}
}
}
return new int[]{0,0};
}
int[] nums = new int[]{12, 11, 7, 2};
var res = Main(nums, 13);
Console.WriteLine($"result = {res[0]} and {res[1]}");

>doesn't like recursion
You fories and whileies disgust me

Really? It's just the last two number to make the next

recursion is costly, not always appropriate

I mean yeah. I understand it. I just can't code it.

Start with facc,
from there fib is a little step.

tail recursion has a cost of loop faggit

I know there's a nice pretty maths solution that doesn't involve recursion for value at n, but I haven't gotten to write anything recursive in ages.
Rate my pajeet stack overflow, nerds.

This is C# right?
Do people really use the big arrow instead of writing real c#?

Yes. By big arrow do you mean the lambda / expression body arrow =>?
I'd probably argue that it's one of the few things that is real C#, being that the language started as a Java clone.
If you're unfamiliar, it's traditionally used for lambda syntax in delegates, which was a pretty common answer to function context pointers. This exploded in popularity though with LINQ, which is still where you'll probably see most => meme arrows.
There's a bunch of cool things you can do with them though, including using them for method expression bodies ( which is extra powerful now you can have functions inside of function scopes like any modern language ) and my personal favourite use is for a shorthand getter property.
public int OCPlsDoNotSteal
=> _otherperson.CopiedHomework;

which is a syntactically clean way to make a getter for good immutable shit.

I don't use LINQ because I care about performance.
My understanding is that the fat arrow is just sugar for { }

That's a fair enough understanding I suppose, for what limited cases you'll probably see it.
I just don't use C# for anything performance intensive. It's main power is in collections, data, and top level applications.
I'd use lambda for bindings, delegates, and work on non-load data. I find LINQ is very useful for writing things from SQL queries to general use algorithms. If it needs to be fast, it'll be written in something like D. And maybe for some libraries I'll write segments in tight loops instead.
Worth also noting that LINQ is starting to get spookily fast as they're making the compiler for it smarter and smarter. It's also absolutely brilliant anywhere you're using anonymous objects.

Was a TA for years.
You need to learn the basics of looping problems. there's a few universally applicable looping methods, that you can then modify to fit most problems to slap together a brute force answer, basic CS 101 shit they "Should teach". Using A+B as example.
Double for "n^2" loop , does all elements incrementing all B before changing A, then redo until done.
Recursive solution loop, compute a solution using other solutions.
"skip N" loops of form a0 + a1, i +=2.
"Nlogn problem solving" which is just half diminishing with comparing between merges.
This is brain dead shit, but you can solve most problems like this. You won't be a rockstar but you'll get through it. Grow some nuts m8

blog.codinghorror.com/separating-programming-sheep-from-non-programming-goats/

Maybe you're just not good at programming. I've met people in my life who just can't grasp code, you sound like one of those people.

My advice would be to find something else you're good at. You could probably train yourself into a code monkey, but ask yourself, do you want that?

just be a web developer

It can, in fact, be done tail recursively in O(n) time and O(1) memory.

none of these are impressive in any way

Yes, it's simply base cases, then fib(i-1) + fib(i-2). You can use memoization/DP to make a table to significantly increase running time since the naive implementation is O(2^n).

Not sure what OPs problem is

What shitty university was it? Any school worth it's salt would not pass a student without studying unless said student was literally Einstein or something

That's honestly not impressive at all. Perhaps you should work on social/writing skills instead

Most of the time it's not the studying, it's the exams that matter. Most classes are "mandatory", but when you have easily 100 students per class, nobody ever checks. And a shit uni could easily not have any smaller classes/sessions, meaning you'd be able to not go there for the entire year but as long as you pass end of year exams you're good.

And if it's a shit uni exams could easily be complete horseshit as well.

Who the fuck do they reject? Fucking incarcerated felons?

for index, fibonacci_number in enumerate(fib()):
print('{i:3}: {f:3}'.format(i=index, f=fibonacci_number))
if index == 10:
break

>Smoke a lot of weed

stopped reading there

>leetcode.com/problems/two-sum/#/description

two for loops: O(n^2)

sort the array in O(n log n) and add from both ends, increasing the index of the smaller number if the sum is below the target, decreasing the index of the bigger number if the sum is above the target : still O(n log n)

If the numbers are small and you want to invest O(max number) space you can do it in linear time:

Use an array index_of_number[ ], and use a for loop in the original array: compute target - a[i], if there is a stored index in the new array print it and i, otherwise set index_of_number[ a[i]] = i

My university has 95+% acceptance (no one applies) and as little of CS majors I think even our program's not that shitty.

>4 hours trying to work on an OS
>can't write the simplest algorithm possible
lol